table of contentsdrupal blocks are best described as content containers. they are the primary tool...
TRANSCRIPT
1.1
1.2
1.3
2.1
2.2
3.1
3.1.1
3.1.2
3.2
3.2.1
3.2.2
3.2.3
3.2.4
3.2.5
3.3
3.3.1
3.3.2
3.4
3.4.1
3.5
3.5.1
3.5.2
3.5.3
3.6
3.6.1
4.1
4.2
TableofContents
Part0:GettingStarted
Coversheet
CERN:WorkingwithWebDAV
CERN:WorkingwiththeCloudEditor
Part1:MigrationBackgroundInformation
Whatcanbemigrated?
AdditionalResources
Part2:SiteBuilding
Blocks
WorkingwithBlocksandThemeRegions
WorkingwithCustomBlockTypes
ContentTypesandFields
WorkingwithContentTypes
WorkingwithFields
WorkingwithViewModes
WorkingwithParagraphs
WorkingwithCERNPatterns
Views
WorkingwithViews
WorkingwithViewsDisplayTypes
Workflows
WorkingwithWorkflows
RolesandPermissions
WorkingwithUserAccounts
WorkingwithRolesandPermissions
CERN:LinkingUserRoleswithEGroups
CERNPageTypes
CERNLandingPage
Part3:SiteStyling
WorkingwithThemes
ThemeInheritance
1
4.3
4.4
4.5
4.5.1
4.5.2
4.5.3
4.6
4.6.1
4.6.2
5.1
5.2
5.3
CERNBaseandCERNOverride
ThemeConfigurationSettings
AssetLibraries
AssetLibraries:Introduction
AssetLibraries:Dependencies
AssetLibraries:Properties
Twig
Twig:TemplateFilenameConventions
Twig:AddingAssetLibraries
Part4:BonusMaterial
WorkingwithMultipleLanguages
WritingCustomMigrations
AdditionalResources
2
CERN-WorkingwithamigratedD8siteDrupalversion:8.7.0Curriculumversion:3Documentversion:1
Credits:Thisguideisbasedinpartonthefollowingmaterial:
http://drupal.org/documentation
Coversheet
3
WorkingwithCERNWebDAVTomanuallyuploadmodulesorthemestoyourCERNDrupalsiteyouneedtoaccessyoursite'ssourcecodedirectoryononeofCERN'sservers.
YoucandothisviatheWebDAVprotocoldescribedhere:https://information-technology.web.cern.ch/book/drupal-infrastructure-services/site-management/file-access
Inshort:
useyourWebDAVclientofchoicefortheoperatingsystemyouuseconnectto: YOURSITENAME.web.cern/_webdav(replaceYOURSITENAMEwithyoursite'sname)protocol:securewebdav(sometimescalledwebdavs)provideyourCERNusernameandpassword
Youcannowcopyfilestoandfromyoursite'ssourcecodedirectory.
WARNING:
Donotremoveanythingunlessyou'reabsolutelysurewhatyou'redoing.Ifyoudoremovemodulesorthemes,onlydosoAFTERyou'veCOMPLETELYuninstalledthem.
CERN:WorkingwithWebDAV
4
WorkingwiththeCloudEditorTrainingsites:
TRN1
https://test-d8-migration-trn1.web.cern.chusername:yourCERNusernamepassword:yourCERNpassword
https://ide-trn1.pathwayx.iousername:cernpassword:cern
TRN2
https://test-d8-migration-trn2.web.cern.chusername:yourCERNusernamepassword:yourCERNpassword
https://ide-trn2.pathwayx.iousername:cernpassword:cern
...
TRN10
https://test-d8-migration-trn10.web.cern.chusername:yourCERNusernamepassword:yourCERNpassword
https://ide-trn10.pathwayx.iousername:cernpassword:cern
CERN:WorkingwiththeCloudEditor
5
Whatcanbemigrated?manuallycreatedcontenttypesvocabulariesmenus
nodesmenususerstaxonomytermsmanuallycreatedblockscomments
sitenamesitesloganfrontpagesettingroles
Whatcannotbemigrated?moduleswithoutamigrationpathviews
Whatcanbemigrated?
6
AdditionalResourceshttps://www.drupal.org/docs/8/upgradehttps://thinktandem.io/blog/2018/07/24/writing-a-custom-drupal-8-module-upgrade-path/
AdditionalResources
7
Blocks
Blocks
8
WorkingwithBlocksandThemeRegionsTheBlocksadministrationpagecanbefoundathttp://example.com/admin/structure/block,alsoavailableatAdministration>Structure>BlockLayout.
Drupalblocksarebestdescribedascontentcontainers.Theyaretheprimarytooltoorganizeyoursite'scontent.
Blockscanholdstaticcontent,dynamiclistsofcontentandfunctionalitysuchasaloginformwithusernameandpasswordfields.
Blocksareeitheraddedmanuallyorprovidedbyamodule.Themoremodulesyouenable,themoreblockswillbecomeavaillableforyoutoplaceinthethemeregionsofyourchoosing.
Assigningblockstoregions
Oncedefined,blockscanbeplacedinanyoftheregionsyourthemeprovides,suchasasidebarorthefooterregion:
CreatingnewblocksToaddacustomablockwithstaticcontent:
1. clickontheCustomblocklibrarylinkatthetopoftheBlockLayoutadministrationpage.2. ClickontheAddcustomblockbutton
WorkingwithBlocksandThemeRegions
9
Theinterfacetomanagecustomblocksisquitesimilartotheinterfacetomanagecontent.AsofDrupal8,blocksarefieldable.Asaresult,thesameFieldUIisusedtomanageblocksand,shouldyouwishtodoso,addfieldstocustomblocktypes:
Blockdescription:Blocklabel(title)displayedontheBlockadministrationpage.Blockbody:theinformationdisplayedbytheblock
Blockinstanceoptions
Oncecreated,yourcustomblockisavailabletobeassignedtoaregionviaAdministration>Structure>BlockLayout:
WorkingwithBlocksandThemeRegions
10
You'venowplacedaninstance(acopy)ofthatblockinacertainregion.Whenyougoandconfigurethatinstance,additionalblockoptionsbecomeavailable:
title:Blocklabel(title)displayedtositevisitorsafteryouplacetheblockinaregion.
Contenttypes:showthisblockonlyonpagesthatdisplaycontentofthegiventype(s).Ifyoudon'tselectanycontenttypes,theblockwillbeshownonallpagesthatmeetyourotherdisplayconditionregardlessofcontenttype.
Visibilitysettings:
Pages-setwhichpagestheblockshouldorshouldnotbedisplayedon.
Roles:showthisblockonlytouserswiththeselectedrole(s).Ifyoudon'tselectanyroles,theblockwillbevisibletoallusers.
Region:settheblockregionwheretheblockshouldappearonyoursite.YoucanalsosetthisdirectlyonthemainBlocksadministrationpage.
WorkingwithBlocksandThemeRegions
11
WorkingwithBlocksandThemeRegions
12
WorkingwithCustomBlockTypesInDrupal8blockshavebecomemuchmorepowerfulthaninDrupal7.
Theycannowweplacedindifferentregionsatthesametime,andtheyhavebecomefieldable,whichmeansyoucanaddcustomfieldstothemandusethemasminicontenttypes.
Howtocreatecustomblocktypes
AsofDrupal8,blockshaveblocktypes,sobeforeyoucancreateacustomblock,youfirstneedtocreateacustomblocktype,andthencreateablockofthattype.Thisprocessisidenticaltoworkingwithcustomcontenttypes.
1. CreateanewcustomblocktypeatAdmin>Structure>BlockLayout>CustomBlockLibrary>BlockTypes(/admin/structure/block/block-content/types)
2. Thenewblocktypenowappearsinthelistofcustomblocktypes.3. Addfieldstothenewblocktypeviaits"managefields"link.4. CreateanewblockatAdmin>Structure>BlockLayout>CustomBlockLibrary(/admin/structure/block/block-
content/types)5. Choosethenewlycreatedcustomblocktypefromthelistofavailableblocktypes.
Whentocreatecustomblocktypes
Itcanbedifficulttodecidewhethertobuildacustomcontenttypeoraacustomblocktypesinceyoucanaddfieldstobothofthem.
Afewrulesofthumbtohelpyoudecide:
iftheinformationshouldbeviewablestand-alone,withitsownaddress,useacontenttypeiftheinformationismeanttobeshownalongside(many)otherpages(mostlyinasidebar),useablocktype.iftheinformationfeelsmorelikeabuildingblocktobeusedtocreatelandingpages,anddoesn'treallystandonitsown,useablocktype.
WorkingwithCustomBlockTypes
13
ContentTypesandFields
ContentTypesandFields
14
WorkingwithContentTypesUserswiththeAdministercontenttypespermissionhavetheabilitytocreatenewcontenttypesandaddmodifyexistingones.
Customcontenttypesgiveyoutheflexibilitytoaddanddeletefieldsandconfiguredefaultsettingsthatsuitthedifferentneedsofvarioustypesofsitecontent.
ToaddnewcontenttypesinDrupal8,navigatetoAdministration>Structure>ContentTypes>Addcontenttype(http://example.com/admin/structure/types/add).
InDrupal8,aContentType'sconfigurationconsistsoftwoparts:
baseconfigurationfieldconfiguration
Thebaseconfigurationofacontenttypedefinesthedefaultbehaviorandpropertiesofthecontenttype.
Examplesinclude:
statuspublishedbydefaultornot?associatedwithoneormoremenus?display"Authoredby{name}on{date}"?...
ThefieldconfigurationdefineswhichadditionalfieldsareaddedtotheContentType,ifany,andhowtheyshouldbedisplayed.
FieldsarediscussedinmoredetailintheWorkingwithFieldssection.
WorkingwithContentTypes
15
WorkingwithFieldsContentTypesarefieldable,aDrupalismwhichmeansthatthroughDrupal'sFieldUIyoucanaddadditionalfields,reorganisefields,anddefinehowthefieldsshouldbedisplayed.
Addingafield
Thereareseveraldecisionsyouwillneedtomakewhendefiningafield:
Namingafield
Afieldhasalabel(thenamedisplayedintheuserinterface)andamachinename(auniqueidentifierusedinternally).
Note:thelabelcanbechangedatwilllateron,butthemachinenamecannot.
Definingwhattypeofdatathefieldwillcontain
Thechoiceoffieldtypeisdrivenbythetypeofdatayouwantthefieldtostore.Eachfieldtypehasspecificfeaturesyouwon'tfindonotherfields.
Example:
"Integernumber"fieldshavebuilt-invalidationrulestoensureentereddataisnumericalandonlycontainswholenumbers.Datefieldshaveabuilt-incalendarwidgetforeasydateselectionandhavedate-relatedvalidationrules.
Note:
afteryou'vecreatedthefieldyoucannolongerchangeitstype.
Defininghowthedatawillbeenteredanddisplayed
Eachfieldtypehasoneormoreassociated"displaywidgets",eachofwhichprovidesamechanismfordatainputwhenyouareediting(textbox,selectlist,checkboxes,fileupload,...).
Eachfieldtypealsohasoneormoredisplayoptions,whichdeterminehowthefieldisdisplayedtositevisitors.Thewidgetanddisplayoptionscanbechangedafteryouhavecreatedthefield.
Defininghowmanyvaluesthefieldcancontain
Foreachfieldyoumustdefinethenumberofvaluesitcanstore:
WorkingwithFields
16
onevalueaspecificmaximumnumberofvaluesanunlimitednumberofvalues.
Example:AProductIDfield(SKU)willonlyholdasinglevaluewhileaphonenumberfieldmigghtstoremultiplevalues-oneforeachnumber.
Thissettingcanbechangedafteryouhavecreatedthefield,butifyoureducethemaximumnumberofvaluesafterdatahasalreadybeenentered,youmayloseinformation.
ReusingafieldPreviouslydefinedfieldscanbereused.
Example:Ifyoudefineacustomimagefieldforonecontenttype,andyouneedtohaveanimagefieldwiththesamesettingsonanothercontenttype,youcanaddthesamefieldtothesecondcontenttype.
Caution:Somesettingsofareusedfieldaresharedacrossallofitsinstances,whileothersettingsareuniquetoeachinstance.Forexample,thelabelofatextfieldisuniquetoeachinstance(youcannamethefield"BookTitle"ononeContentType,whilecallingit"ProductionTitle"onanother),whilethesettingforthenumberofvaluesisshared(changeitforoneinstanceandalloftheotherinstancesofthesharedfieldaremodifiedaswell).
Whyreuseafield
Reusingfieldscansaveyoutimeasitavoidsredefiningthesamefieldsoverandoveragain.
Reusingfieldscanbeadvantageousasitallowsyoutoreusespecificcustomthemecodeandthemelogicusedtodefinehowthatfieldshouldbedisplayed.
WhyNOTtoreuseafield
Advancedfield-levelconfiguration
Ifyou'reunsureofcertainadvancedconfigurationsyoumaywanttodoonafieldlevelinthefuture,it'sbetternottoreusefieldstoomuch.
Example:Withtheuseofadditionalmodulesit'spossibletoconfigurefield-levelpermissionsandsetupscenariossuchas"Onlyuserswiththe'Staff'rolecanuseandseethe'Internalcomment"field.Thesepermissionswillapplyacrossallinstancesofthatfield-itwon'tbepossibletoturnthemonoroffonaper-contenttypebasis.
Feature-baseddeployment
Theoften-usedconfigurationdeploymentmechanismFeatures(offeredbytheFeaturesmodulepackagessetsconfigurationtogetherintofeaturemodules.Ifafieldisreusedaccrossmultiplecontenttypes,thatfielddefinitionbecomesadependencyoftwodifferentsetsofconfigurations-ascenariowhichFeatureshassometroublewith.
WorkingwithFields
17
WorkingwithViewModes
WhatisaViewmode?
Howanentity(suchascontent,auseroracomment)isdisplayed,dependsonthecontextinwhichitisshown.Thiscontextisknownasaviewmode.
Examplesofviewmodesare:
afullpageofthecontentwithallthefieldvaluesateaserofthecontentwithathumbnailimageandaReadmorelinkafulluserprofilewithazoomableportraitphotoauseravatarwithusernameandalinktotheprofile
WorkingwithViewModes
18
Everyviewmodecanbeconfiguredthroughtheadministrationpages.ToseetheconfigurationoptionsfortheviewmodesoftheRecipecontenttype,navigatetoStructure>Contenttypes(admin/structure/types)andclickManagedisplayfromthedropdownbutton.
Ineachviewmode,allfieldscanbehiddenordisplayed.Iftheyaredisplayed,youcanchooseandconfigurethefieldformatter.
Whatisafieldformatter?
Afieldformatterisasettingfordisplayingthefieldvalues.Forexample,longtextfieldscanbedisplayedtrimmedorfull-length,andtaxonomytermreferencefieldscanbedisplayedinplaintextorlinkedtothetaxonomytermpage.ConsulttheManagedisplaypagetoseethefieldformattersforthefieldsoftheRecipecontenttype.
WorkingwithViewModes
19
WorkingwithParagraphsTheusualwayofconstructingthecontentofapageinDrupalisbyusingthe"body"fieldtostoreallpageheaders,content,images,links,andsoon.Typically,onanygivenDrupalpageeverythingrevolvesaroundthe"body"field.
Whilethisisavalidapproach,itdoesn'tworkwellinallscenarios.It'strickytobuildresponsive,complex,mediaheavypagesthisway.
Anotherdisadvantageisthatit'sdifficulttoreuseexistingcontentwithinthebodyfield.
The"Paragraphs"approachisanalternativewayofassemblingpagecontent:Drupal’s"body"fieldisremoved,andinitsplacesitebuilderscanchoosefromanumberofpredefinedcomponents,
Paragraphtypes
It'suptothesite'sdevelopmentteamtodecidewhichtypesofparagraphs(components)tocreateandmakeavailabletoindividualsitebuilders.
Theseparagraphtypesofteninclude:
textwithalignedimagefull-widthimageslideshowlistofitems
TheseParagraphseffectivelybecomecomponentsthatsitebuilderscanusetoassemblepages.
Recap
Contenttypesareusedtodefinedifferenttypesofcontent,andtheirproperties.Displaymodesareusedtodefinedifferentwaysinwhicheachcontenttypecanbedisplayed.Complexpagesareassembledfromexistingcontent,usingaselectionofcomponents.
WorkingwithParagraphs
20
WorkingwithCERNPatternsDocumentation:https://webtools.web.cern.ch/technologies/drupal/expansion/cern-components
Patterns
Atthetimeofwriting(June2019),thefollowingCERNPatternsareavailable:
PreviewCardPreviewListFAQListAgendaBoxAgendaComingsoon
WorkingwithCERNPatterns
21
Views
Views
22
WorkingwithViews
Viewsisaquerybuilder
ThefirstfundamentalthingyouneedtoknowaboutViewsisthatitisatooltobuilddatabasequerieswithoutwritingasinglelineofSQLcode.
ThenextthingyouneedtounderstandistheUserInterface.WefindtheViewsinitial"wizard"doesconfusenewlearners,thoughitismeanttobeaquick-startsimplifieduserinterface.
Justkeepinmind,likeanygoodwizard,onceit'sdoneitsmagic,itvanishes.Thewizardallowsyoutoselectsomeofthesettingsquickly.
ThemainViewsadministrativeinterfaceiswhereeveryviewiseditedandmaintained,oncecreatedwiththeinitialwizard.Theadministrativeinterfacecontainsavastamountofoptions.
WorkingwithViews
23
Tostartmakingsenseofeverythingthat'sgoingonhere,trytothinkofthemastwogroupsofactions:
whatdatatoselectfromthedatabasehowtodisplaythedatafetchedfromthedatabase:
Redarea:whattoselectandfilterfromthedatabase.
DisplaysFormatSortCriteriaPageSettingsPager
Greenarea:howtoformattheinformationandwheretodisplayit.
FieldsFilterCriteraContextualFiltersRelationshipsExposedForm
Whatdoyouwanttoselect?
Selectbasetabletostart(youcancombinetableswithrelationships).ApplyfiltersSelectfieldsor
Whereandhowshoulditappear?
Chooseaformatsuchaslist,table,etc.Chooseadisplaysuchaspages,blocks,RSSfeeds.WithadditionalmodulesmoreViewsdisplaytypesareavailable.
WorkingwithViews
24
WorkingwithViewsDisplayTypesOneViewoftencontainsmorethanoneDisplay,eachservingadifferentpurpose,andeachhavingdifferentsettings.
InadditiontothedefaultMasterdisplay,aviewusuallycontainsdisplaysofthetypePageorBlock.LesscommonlyusedDisplayTypesincludeFeed,Attachment,Embed,andEntityReference.
MasterDisplay
TheMasterdisplaycontainsthedefaultsettingforagivenview.Everyadditionaldisplay,regardlessoftheDisplayType,willinherititsdefaultsettingsfromtheMasterdisplay.
TheMasterdisplayishiddenbydefault.It'sonlyvisibleifyouhaven'tcreatedanyotherdisplaysyet,orifyouhaveenabledthe"Alwaysshowthemaster(default)display"optionintheoveralViewssettingsatStructure>Views>Settings(admin/structure/views/settings):
PageDisplay
Pagedisplaysreturntheviewresultasapage,availableatagivenURL.
WorkingwithViewsDisplayTypes
25
Block
Blockdisplaysreturntheviewresultasablock:
BlocksgeneratedbytheViewsmodulearenodifferentfromtheotherDrupalblocksavailableatStructure>Blocklayout(admin/structure/block).
Feed
FeeddisplaysreturntheviewresultasanXMLfeed,availableatagivenURL.
Thefollowingfeedformatsareavailablebydefault:
RSSOPML
WorkingwithViewsDisplayTypes
26
Attachment
WithAttachmentDisplaysyoucanattachoutputtoanyoftheotherdisplaysinthesameview.
Theattachmentsettingsletyouspecify:
whichdisplaytoattachtowheretoattachit:before,after,orboth
EntityReferenceEntityReferenceDisplaysreturnalistofentitieswhichcanbeusedasthelistofpotentialvaluesforEntityReferencefields.
UsuallywhenyoucreateanEntityReferencefieldyouonlyindicatewhichtypesofentitiescanbereferenced(Users,Articles,...).
Ifyouwantmorecontroloverexactlywhichentitiescanbereferenced,oryouwanttoinfluencetheorderinwhichtheyappearintheEntityReferencefield'slistofoptions,youcanuseanEntityReferenceDisplay.
Examplescenario:
YouwanttoBasicPagestobeabletorefertooneormoreexistingArticlessoyoucanhaveablock"RelatedArticles"oneachBasicPage.
However,youonlywantpeopletobeabletoreferencecertainArticles,ratherthananyarticle.
Step1:createaviewwithanEntityReferencedisplay,andgiveitthetitle"Articles".
Step2:addanEntityReferencefield(Contentreference)totheBasicPageContentType,andcallit"RelatedArticles".
Step3:changetheReferencemethodfrom"Default"to"Views:Filterbyanentityreferenceview",andselecttheviewwiththeEntityReferencedisplayyoucreatedinstep1.
WorkingwithViewsDisplayTypes
27
Embed
EmbedDisplaysaremeanttobeprogrammaticallyincludedsomewhere.
Assuchtheydodon'thavean"EmbedSettings"configurationsectionthewaytheotherdisplaysdo.Anysettingssuchasfiltervaluesarepassedinprogrammatically.
Intheoryeverytypeofdisplaycanbeprogrammaticallyembedded.TheadvantagesoftheEmbedDisplaytypeare:
itsoutputcontainslessmarkup,sothere'slessmarkuptooverrideitssimplernaturemeansDrupalcanusefewerresourcestofullyrenderit,comparedtotheotherdisplaytypes.
ProgrammaticallyEmbeddingViewDisplays
Possiblewaystousecodetoembedaviewsdisplayinclude:
usingacustommodule,usingthe views_embed_view()PHPfunction.Seeapi.drupal.orgfordetails.usingaTwigtemplatefile,usingthe drupal_view()TwigfunctionprovidedbytheTwigTweakmodule.
WorkingwithViewsDisplayTypes
28
WorkingwithViewsDisplayTypes
29
Workflows
Workflows
30
WorkingwithWorkflowsThecoreWorkflowsModuleprovidesagenericworkflowengineontopwhichyoucandefinedifferentworkflows,eachwiththeirownworkflowstatesandworkflowtransitions.
Workflowsapplytoentities.Whichexactentitytypesagivenworkflowappliestodependsonthatworkflow'ssettings.
WorkflowsModule
ToenableworkflowsfunctionalityyoumustfirstinstalltheWorkflowsModule,whichispartofDrupalcorebutnotinstalledbydefault.
OncetheWorkflowsModuleisinstalled,youcanseetheavailableworkflowsatConfiguration>Workflow>Workflows(admin/config/workflow/workflows):
ContentModerationModuleBydefaulttherearenoworkflowtypesavailable.Youmustinstallamodulethatprovidesoneormoreworkflowtypes,suchasthecoreContentModerationModule:
WorkingwithWorkflows
31
Onceinstalled,theEditorialworkflowbecomesavailable:
NOTEatthetimeofwriting(D8.6.10)newworkflowtypescanonlybecreatedincode,bywritingacustommodule.Thismaychangeinthefuture.
WorkflowComponents
YoucanfindtheEditorialworkflow'scomponentsatConfig>Workflow>Workflows>Editorial(admin/config/workflow/workflows/manage/editorial)
Workflowshavethreemaincomponents:states,transitions,andtargetitems.
States
Anitemtowhichaworkflowappliesalwaysfindsitselfinoneofthedefinedworkflowstatesananygiventime.
TheEditorialworkflowhastheDraft,Published,andArchivedstates.IfthisworkflowisenabledfortheArticlecontenttype,atanygiventimeeacharticleisintheDraft,Published,orArchivedstate.
WorkingwithWorkflows
32
Foranygivenworkflowyoucanadd,rename,andremoveworkflowstates.
Transitions
Transitionsdefinebetweenwhichofthedefinedstatesanentitycanchange.
ConsidertheEditorialworkflow,withstatesDraft,Published,andArchived,andthefollowingtransitions:
CreateNewDraftPublishArchiveRestoretoDraftRestore
Youwon'tbeabletochangeanentitydirectlyfromDrafttoArchived,becausenotransitionbetweenthosetwostatesexists.You'llneedtodothisinmultiplesteps:
DrafttoPublishedPublishedtoArchived
WorkingwithWorkflows
33
Alsonotthatyouwon'tbeabletomakechangeswhilekeepinganentityintheArchivedstate,becausenotransitionbetweenthosetwostatesexists.Thestepsyou'llneedwillbe:
ArchivedtoDraftDrafttoPublishedPublishedtoArchived
Howfaryouwanttogoinenforcingamulti-stepworkfloworprovidingtransitionstoallowdirectchangesbetweenallstatesdependsentirelyonyoureditorialteam'sneeds.
TargetItems
Theentitytypesaworkflowcanbeappliedtoarelistedatthebottom:
AcommonconfigurationscenarioistoapplytheEditorialworkflowtooneormoreContenttypes.
Changinganindividualentity'sWorkflowState
Ifyou'veappliedtheEditorialworkflowtoaContenttype,forinstanceArticles,amoderationstatefieldappearsoneacharticle'scontenteditform(node/add/article),replacingthedefaultPublishedcheckbox:
WorkingwithWorkflows
34
WorkingwithWorkflows
35
RolesandPermissions
RolesandPermissions
36
WorkingwithUserAccounts
Managinguseraccounts
Thelistofalltheuseraccountsislocatedathttp://example.com/admin/peopleorviaAdministration>People:
SimilarlytotheadministrativeContentlisting,thisscreenletsyoutoviewalluseraccounts,filterthemonrole,permissionandstatus,andperformbulkoperationssuchasdelete,blockandunblockonthem.
Viaauser'seditlinkyoucangoinandeditanindividualuser'saccountdetails,includingtheirusername,password,statusandassignedroles:
CreatingauserisdonethroughtheAdduserlinklocatedinthetoplefthandsideofthescreenabovethefiltersettings.Theentryformisidenticaltotheoneusedforeditingusersandprocessisstraightforward:fillinthemandatoryfields(username,password,emailaddress)andanyoftheoptionalonesandsave.
Managinggeneralaccountsettings
WorkingwithUserAccounts
37
Managinggeneralaccountsettings
Whilemanagingindividualuseraccountdetailsisdonethroughhttp://example.com/admin/admin/people,definingtheglobalcharacteristicsandsettingsofalluseraccountsisdoneathttp://example.com/admin/config/people/accounts,alsoavailableviaAdministration>Configuration>People>Accountsettings:
1. Definetheusernametodisplaywhenshowingcontentand/orcommentsbyanonymous(non-authenticated)users.
2. Definewhichroleshouldbeconsideredtheadministratorrole
3. Settingsrelatedtotheregistrationandcancellationofuseraccounts.Mainly:canuserscreatetheirownaccountsorcanonlyadministratorsdoso.
4. Whenauseraccountiscancelled,whatshouldhappentothecontentcreatedbythatuser?
5. Definethecontentoftheemailsthataresentoutuponvarioususerrelatedeventssuchasaccountcreation,accountcancellationandpasswordrecovery.
6. SinceusersareentitieswithinDrupal7,theyarefieldable-fieldscanbeattachedtothemsoyoucanbuildmoreextensiveuserprofiles.
Extendinguseraccountswithnewfields
Themanagefieldstabonhttp://example.com/admin/config/people/accounts/fieldsopensupthefamiliarFieldUIscreenthatisalsousedtoaddfieldstoContentTypes:
WorkingwithUserAccounts
38
Toaddfieldstousers,followthesamestepsasyouwouldwhenaddingfieldstoContentTypesorotherentitytypes.
WorkingwithUserAccounts
39
WorkingwithRolesandPermissions
Understandingrolesandpermissions
Drupalprovidesasystembasedonrolesandpermissionstoallowyoutolimitaccesstoadministrativefeaturesandotherfunctionalitytocertaingroupsofpeople.
Theprincipleisstraightforward:
1. addarole(e.g.'editor')2. assignpermissionstothatrole(e.g.'cancreatearticles'and'candeletearticles')3. assignoneormoreuserstothatrole
Howrolesarenamedandhowmanyrolesyoucreateiscompletelyuptoyou:
youcouldhaverolesthataremodelledonexistingreal-worlddepartmentsinyourorganisation,suchas'editors','translators','management'.youcouldhaverolesnamed'members','partners','vendors'.youcouldhaveasingle'administrator'roleifonlyyouandahandfulofpeoplemanagethewholesite.
Oncearoleisadded,oneormorepermissionscanbeassignedtoit.PermissionsaredefinedbyDrupalitselfaswellasbyadditionalmodulesyouenable.If,forinstance,youweretoenabletheContactmodulewhichletsyoucreatecontactforms,anewsetofpermissionswillbecomeavailable.Inthisparticularcasethosewouldbe:
AdministercontactformsandcontactformsettingsUsethesite-widecontactformUseusers'personalcontactforms
Note:
Drupal'srolesandpermissionsarecumulative.negativepermissions(restrictions)arenotpossible.
Themorerolesapersonhas,themorepermissionsheorsheisgranted.Aspermissionscannotberestrictive,arolecannottakeawaypermissions,onlygiveapersonmorepermissions.
ThisalsomeansthatitisimpossibleforDrupalrolestoconflictwitheachother,asisbethecaseinothersystemswhereonerolecangrantaspecificpermissionandanotherrolecandenythatsamepermission,effectivelycausingaconflictifauserisassignedboththoseroles.
Drupalhastwospecial,system-definedroleswhichcannotberemoved:
TheAnonymoususerrole,assignedtoeveryvisitortothesitewhohasnot(yet)loggedin.Sinceeverynon-authenticatedvisitortothesitewillhaveallthepermissionsassignedtothisrole,itisimportanttobeverycarefulwhenconfiguringthisrole
TheAuthenticatedUserrole,assignedtoeveryuserwhologsintothesite,regardlessofanyotherrolethatmightbeassignedtothatuser.Assignpermissionsthatarecommontoall(non-anonymous)rolestotheAuthenticatedUserrole,andtheninadditionaddspecificpermissionstospecificrolesinagranularfashion.
ManagingrolesRolesandpermissionsaremanagedviatherolesandpermissionstabsrespectively,foundathttp://example.com/admin/config/people/permissions,alsoavailableatAdministration>people.
WorkingwithRolesandPermissions
40
Rolesaremanagedathttp://example.com/admin/people/permissions/roles:
Assigningpermissionstoroles
Clickingtheeditpermissionslinknexttoaroleleadstoalistofallthepermissionscurrentlydefinedinthesystem.Simplyselectthepermissionsyouwanttoassigntothatparticularroleandsave:
AssigningrolestousersRolescanbeassignedtousersintwoways:
WorkingwithRolesandPermissions
41
1. througheachindividualuser'sprofilesettings:
2. bygoingtoAdministration>People,selectinganumberofusersandperformingtheupdateactionAddaroletotheselectedusers:
WorkingwithRolesandPermissions
42
LinkingUserRolesandEGroupsWhileit'spossibleforyoutomanuallyassignpeopletothoseDrupalrolesyoucreated,atCERNyoushouldNOTdothis.
Ifyouneedtogivedifferentgroupsofpeopledifferentsetsofpermissions,useEGroups:
1. CreateanewEGroup2. CreateanewDrupalrole3. AssignthedesiredpermissionstothenewDrupalrole4. LinktheDrupalroletotheEGroupatAdmin>Configuration>Simplesamlphpauthsettings>Userinfoandsyncing
(/admin/config/people/simplesamlphp_auth/sync)
Syntax
Whilethissyntaxcanbecomequitecomplex,here'sanexampleitssimplestform:
administrator:egroups,=,drupal-admins-test-d8training-demo
Theabovestatementassignsthe'administrator'Drupalroltotheegroup'drupal-admins-test-d8training-demo'.
Whenindoubt,don'thesitatetoraiseasupportticket.
CERN:LinkingUserRoleswithEGroups
43
CERNPageTypes
CERNPageTypes
44
LandingPageLandingpagesareusedaseye-catchingpagesthatleadavisitordeeperdownintoyoursite.Theyarerarelythefinaldestinationofauser'sjourney,andassuchtendtobeusedfornavigationratherthanasaplaceholderforimportantcontent.
Documentation:https://webtools.web.cern.ch/technologies/drupal/expansion/landing-page
Sections&Components
AftercreatingaLandingPage,thefirstthingyouaddisoneormoresections.Youcanthinkofeachsectionasapage-widerow.
Insideeachsectionyouwillplaceoneormorecomponents.Youcanthinkofcomponentsaswidgetssuchas"blockoftext","slideshow"and"bannerimage".
Fromatechnicalpointofview,CERNcomponentsareParagraphtypes.IfyouknowhowtoworkwiththeParagraphsystem,youknowhowtoworkwithCERNcomponents.
CERNLandingPage
45
WorkingwithThemesAthemeprovidesaparticularlookandfeelforyourDrupalsiteandismeanttobecompletelyindependentofyoursite'soverallconfiguration.Assuchyoushouldbeabletoswitchfromonethemetoanotherwithoutlosinganyfunctionality.
CoreThemes
Drupalcorecontainsfourthemes:
BartikSevenStark
Bartik
DrupalenablesBartikasthedefaultuser-facingthemeuponinstallation.Itisacleanandsimplethemethatsupportsthecolormoduleandmakesexcellentuseofregions.InadditiontothedefaultregionsDrupalrecommends,theBartikthemehassevencustomregionsforlayingoutblocksinthefooterandsub-footer.
Seven
SevenisDrupal'sdefaultadministrativetheme.BornoutoftheDrupal7UserExperienceproject,SevendrovemanyofDrupal'suserinterfaceimprovementsbetweenDrupal6andDrupal7.Itcontainsveryfewregions;itsfocusisonperformingadministrativetasks.
Stark
StarkisaminimalDrupaltheme.ItsmainpurposeistoexposeDrupal'sdefaultHTMLmarkupandCSS.ItdoesnotprovideanytemplatefilesandbarelyprovidesanyCSSatall,otherthanbasiclayoutstylesthatplacethedefaultsidebarregions.
StarkisagoodthemefordeveloperstocodeagainstwhenwritingCSSfortheirmodules.Itcanalsoassistthemedeveloperswhentryingtotroubleshootissueswherethey'renotpositiveiftheproblemiswiththeirthemeoranothermodule.
EnablinganddisablingthemesDownloadedorcustombuiltthemesshouldbeplacedin:
<drupal-root>/themes/contrib/
and
<drupal-root>/themes/custom/
respectively.
Enablinganddisablingthemesisdoneinawaysimilartoenablinganddisablingmodules.Thelistofavailablethemescanbefoundathttp://example.com/admin/appearence,alsoavailableatAdministration>Appearance:
WorkingwithThemes
46
Anyoftheenabledthemescanbesetasthedefaulttheme(alsoreferredtoastheactivetheme).Clickingonatheme'ssettingslinkleadstotheconfigurationscreenofthatparticulartheme.
DefininganAdministrationtheme
Inadditiontothedefaulttheme,youcanalsoindicatewhichoftheavailablethemesshouldbeusedastheadministrationtheme.Oftenthethemeyouchooseforthepublicfacingpartofthesiteisnotparticularlysuitedforadministrationscreenswhichtendtorequireasimpleandcleaninterfacewithasmuch'screenrealestate'possible.
Globalthemesettingsvs.per-themesettings
Theconfigurationoptionsforaparticularthemeconsistoftwoparts:
Generalsettings,inheritedfromtheGlobalthemesettings,thatcanbeoverriddenonaper-themebasis.
Examplesincludesettingsforacolourschemeandwhichimagetouseforthesitelogo:
WorkingwithThemes
47
Settingsprovidedbythecreatorofthetheme,specifictothatparticularthemealone.
Let'ssayyouinstallathemethathasafocusonbeingusableonmobiledevices.Suchathemecouldprovidesettingsrelatedtohowthelayoutofthesiteshouldbehaveonasmallsmartphoneasopposedtoalargertabletdevice.
WorkingwithThemes
48
Themeinheritance
Basethemesandsub-themes
Drupalthemescan,andoftenare,basedonotherthemes.Anoftenusedscenarioisanorganisationcreatingaso-calledbasethemethatcontainsanumberofpossiblelayoutsforaseveralpagesandelements,anddefinesangenericlook-and-feelandbranding.EachoftheindividualdepartmentscouldhavetheirownDrupalsite(oransiteinstanceinamultisitesetup)andhavetheirowncustomisedtheme.
Oneapproachwouldbefor,say,theHRdepartmenttosimplycopythethemeandadaptittotheirneeds.However,ifchangesaremadetotheoriginalthemetheywon'tautomaticallyappearintothecopies.
Drupal'ssolutiontothisistheconceptofbasethemesandsub-themes.Basethemescanbethoughtofasparentthemes,sub-themesaschildthemes.
Themeinheritanceandtraversal
AswasthecaseinDrupal7,variousbitsandpiecesinDrupalarethemedwithdedicatedtemplatefiles:pages,views,nodes,users,blocks,etc...allhaveoneormorecorrespondingtemplatefiles.
Whenit'spreparingtotheme,say,anode,Drupalcheckswhetherthecurrentlyactivethemecontainsthefile node.html.twig.
Ifthecurrentlyactivethemecontainsthatfile,it'sused
Ifthecurrentlyactivethemedoesnotcontainthatfile,Drupalchecksifabasethemeisdefinedanifso,ifthatbasethemecontainsthatfile.Ifthatbasethemeinturnisasub-themeofyetanotherbasetheme(agrand-paranttheme),thatoneissearchedaswellforthe node.html.twigfile.
Thisprocessendswhenthehierarchicalchainofbasethemesandsub-themesends,orwhena node.html.twigfileisencountered.
Iftraversingthroughthechainofthemeshasnotyieldedanyresult,thecoretemplatefileprovidedbythenodemoduleat/core/modules/node/templates/node.html.twigisused.
Thistraversalofthemes,andfallingbacktoacoretemplatefileisunchangedfromDrupal7,onlynowthetemplatefilesarecalled *.html.twigratherthan *.tpl.php,andtheycontaintwigmarkupratherthanhtmlandphp.
ThemeInheritance
49
CERNThemes:CERNBaseandCERNOverride
CERNBase
CERNBaseisthedefaulttheme,enabledwhenyoucreateanewCERND8site.Unlessyouhaveaspecificthemeneedthatcan'tbefulfilledbyusingCERNBase,thisisthethemeyouuse.
ThisthemeisbuiltfollowingCERN'sbrandinganddesignguidelines,anditscolourconfigurationoptionssuitmostsitebuilders.
ForsitebuilderswhowanttogofurtherandwanttomaketheirownDrupaltemplatefilesandprovidetheirowncssandjavascript,CERNhasbuilttheCERNOverridetheme.
CERNOverride
CERNoverrideisachildthemeofCERNBase:itisanexactcopyofCERNBase,readyforyoutomakeyourchangesbyoverridingorextendingthebasetheme.
TogetstartedwithCERNOverride:
1. RequestaccesstotheGitlab"CERNOverride"project2. DownloadacopyoftheCERNOverridesourcecode(orclonetherepoifyouarefamiliarwithgit)3. Uploadthethemetoyoursite's"/themes/"directory4. GotoAdmin>Appearance(/admin/appearance),findtheCERNOverridethemeamongthelistedthemes,andclick
"enableandsetasdefault".
Youcannowstartmakingchangestotemplatefilesanduploadthemodifiedfilestoyoursite's"/themes/cernoverride"directory.
Themostcommonchangesitebuildersmakeisusingcustomcssclassesintheirpagecontent,andcreatecustomCSScodeintheCERNOverridethemetomatchtheclassnames.
It'sinterestingtoknowthatCERNBaseisbuiltontopoftheBootstrapCSSFrameworkwhichalreadyprovidesready-to-useclassnamesandfacilitiesforeffects,responsivedesign,andaccessibility.Tolearnmoreaboutthis,visithttps://getbootstrap.com/docs/3.3/.
CERNBaseandCERNOverride
50
ThemeConfigurationSettingsEverythemehasitsownsettingspageat admin/appearance/settings/THEMENAME,withsettingssuchas"Logoimagesettings"and"Shortcuticonsettings."
Yourthemecanprovidedefaultvaluesforthesesettingsinafilenamed THEMENAME.settings.yml.
Thefollowexamplesetsthe"usedefaultlogosuppliedbythetheme"and"userpicturesinposts"settings(foundat/admin/appearance/settingsto1(TRUE)whenthethemeisenabledforthefirsttime.
→/themes/custom/THEMENAME/config/install/THEMENAME.settings.yml:
default_logo:1toggle_node_user_picture:1
ThemeConfigurationSettings
51
AssetLibraries
AssetLibraries
52
Assetlibraries:IntroductionD8introducestheconceptofassetlibraries,usedtospecifytheloadingofcustomcssandjsfiles.
Librariescanbedefinedbymodulesandbythemes.
Todefinealibraryinyourtheme,addafilenamed THEMENAME.libraries.ymlinyourthemedirectory,replacingTHEMENAMEwiththenameofyourtheme.
Yourfirststepistodefinealibraryinyour THEMENAME.libraries.ymlfile.Thesecondstepistospecifywhen/wherethislibraryshouldbeincluded;youusuallydothisin THEMENAME.info.yml(discussedbelow).
Basiclibrarysyntax
Example1:alibrarythatreferencesasinglecssfile
library-name:css:theme:css/mycomponent.css:{}js:js/mycomponent.js:{}
Example2:alibrarythatreferencesmultiplecssfiles
library-name:css:theme:css/mycomponent-colors.css:{}css/mycomponent-typography.css:{}css/mycomponent-structure.css:{}
Example3:alibrarythatreferencescssandjsfiles
library-name:css:theme:css/mycomponent.css:{}js:js/mycomponent.js:{}js/otherstuff.js:{}
Example4:alibraryforaslideshow
slideshow:css:theme:css/slideshow.css:{}js:js/slideshow.js:{}
Globalassets
AssetLibraries:Introduction
53
Byconvention,allscriptsandstylesthatshouldbeloadedoneverypageshouldbegroupedintolibrariesnamedglobal-stylingandglobal_scripts:
Example5:globalassets
global-styling:css:theme:css/style.css:{}css/colors.css:{}
global-scripts:js:js/trackers.js:{}js/advertising.js:{}js/animations.js:{}
Addingalibrarytothe.info.ymlfile
Thebasicpropertiesofeverytheme,includingtheassetlibrariestouse,aredefinedintheir THEMENAME.info.ymlfile.
Assumingyour THEMENAME.libraries.ymlfilecontainstheglobal-stylingexamplementionedinexample5,thefollowingshouldbeaddedto THEMENAME.info.yml:
libraries:-THEMENAME/global-styling-THEMENAME/global-scripts
Fullexample
Assumingyourthemeisnamedcorporate:
→/themes/custom/corporate/corporate.libraries.yml:
global-styling:css:theme:css/corpstyle.css:{}
global-scripts:js:js/somescript.js:{}js/otherscript.js:{}
→/themes/custom/corporate/corporate.info.yml:
libraries:-corporate/global-styling-corporate/global-scripts
Loadingassetsfromabasetheme
Ifyourthemeisbuiltontopofabasetheme(seesectionThemeInheritance),yourassetlibrarycanloadfilesfromyourbasethemeaswell.
AssetLibraries:Introduction
54
Thefollowingexampleloads css/components/accordion/accordion.cssfromthebasetheme,and css/style.cssfromthecurrenttheme:
global-styling:base:css/components/accordion/accordion.css:{}theme:css/style.css:{}
AssetLibraries:Introduction
55
AssetLibraries:Dependencies
Dependencies
Incaseswhereyourcustomjavascriptdependsonotherjavascriptfilestobeloadedfirst,youcanspecifiesdependenciesinyourassetlibraries:
Thefollowingexampleensuresthatthefollowinglibrariesareloadedaswell:
thejquerylibrary,providedbyDrupalcorethebasic-sliderlibrary,providedbythesuper_slideshowmodule
slideshow:js:js/slideshow.js:{}dependencies:-core/jquery-super_slideshow/basic-slider
Youwoulddothisifyouwantedtobuilduponthejavascriptprovidedbysuper_slideshow/basic-slider,andwouldusejQueryfunctionstodoso.
Note:inDrupal8jQueryisnolongerloadedbydefaultonallpages.IfyourcustomjavascriptreliesonjQueryyoumustspecifythisdependencyinyourlibrarydefinition.
AssetLibraries:Dependencies
56
AssetLibraries:PropertiesYoucanaddpropertiestoeachassetinyourassetlibraryinsidethecurlybracketsfollowingassetyourtheme'sTHEMENAME.libraries.ymlfile.
Propertyexamples
Conditionalloadingbasedonbrowsertype
Thefollowingexamplespecifies:
load css/style.cssonallpagesonlyload css/style-ie9.csswhenthebrowserisIE9(orlower).Don'tloadonbrowsersthatarenotIE.
global-styling:css:theme:css/style.css:{}css/style-ie9.css:{browsers:{IE:'lteIE9','!IE':false}}
Conditionalloadingbasedonmediatype
global-styling:css:theme:css/style.css:{}css/print.css:{media:print}
FurtherReading
AllD8libraryproperties
https://www.drupal.org/docs/8/theming/adding-stylesheets-css-and-javascript-js-to-a-drupal-8-theme#libraries-options-details
CSSMediaproperties
https://developer.mozilla.org/en-US/docs/Web/CSS/@media
AssetLibraries:Properties
57
Twig
Twig
58
TemplateFilenameConventionsDrupalloadstemplatesbasedoncertainnamingconventions.Youcanoverridetemplatesbyaddingthemtoyourthemeandgivingthemspecificnamesfollowingafilenameconvention.
Note:AfteraddinganewtemplateyoumustclearthecachetomakeDrupalawareofyouraddition.
Thefollowingisashortlistofthemostoftenusedtemplates.PleaserefertoAdditionalReadingformoreexamplesandin-depthinformation.
Note:Youmustreplaceunderscoreswithhyphensinyourplaceholders.
Example:ifthepatternis'page--[nodetype].html.twig'andyournodetype'smachinenameis'promo_events',yourtemplatefilenamemustbe page--promo-events.html.twig.
HTML<head>templatesBasetemplate: html.html.twig
Patternexamples:
html--[internalviewpath].html.twig
html--node--[nodeid].html.twig
html.html.twig
Pagetemplates
Basetemplate: page.html.twig
Pattern: page--[front|internal/path].html.twig
Patternexamples:
page--node--edit.html.twig
page--node--1.html.twig
page--[nodetype].html.twig
page--node.html.twig
page.html.twig
RegiontemplatesBasetemplate: region.html.twig
Pattern: region--[region].html.twig
Patternexamples:
region--highlighted.html.twig
region--footer.html.twig
Blocktemplates
Twig:TemplateFilenameConventions
59
Basetemplate: block.html.twig
Pattern: block--[module|delta].html.twig
Patternexamples:
block--[module]--[delta].html.twig
block--[module].html.twig
block.html.twig
Nodetemplates
Basetemplate: node.html.twig
Pattern: node--[content-type|nodeid]--[viewmode].html.twig
Patternexamples:
node--[nodeid]--[viewmode].html.twig
node--[nodeid].html.twig
node--[content-type]--[viewmode].html.twig
node--[content-type].html.twig
node--[viewmode].html.twig
node.html.twig
Fieldtemplates
Basetemplate: field.html.twig
Pattern: field--[type|name[--content-type]|content-type].html.twig
Patternexamples:
field--node--[field-name]--[content-type].html.twig
field--node--[field-name].html.twig
field--node--[content-type].html.twig
field--node--[field-name].html.twig
field--[field-type].html.twig
field.html.twig
TaxonomyTermtemplatesBasetemplate: taxonomy-term.html.twig
Pattern: taxonomy-term--[vocabulary-machine-name|tid].html.twig
Patternexamples:
taxonomy-term--[tid].html.twig
taxonomy-term--[vocabulary-machine-name].html.twig
taxonomy-term.html.twig
Viewstemplates
Twig:TemplateFilenameConventions
60
Basetemplate: views-view.html.twig
Patternexamples:
views-view--[viewid]--[view-display-id].html.twig
views-view--[viewid]--[view-display-type].html.twig
views-view--[view-display-type].html.twig
views-view--[viewid].html.twig
views-view.html.twig
ViewsFieldtemplatesBasetemplate: views-view-field.html.twig
Patternexamples:
views-view-field--[viewid]--[view-display-id]--[fieldid].html.twig
views-view-field--[viewid]--page--[fieldid].html.twig
views-view-field--block--[fieldid].html.twig
views-view-field--[fieldid].html.twig
views-view-field.html.twig
AdditionalReadingPathbasednamingconventions:https://www.drupal.org/docs/8/theming/twig/working-with-twig-templates#path-based-page-theme-hook-suggestions
Twig:TemplateFilenameConventions
61
Twig:AddingAssetLibrariesYoucanattachanassetlibrarytoaTwigtemplatewiththe ̀ attach_library()functioninany*.html.twigfile.
ExampleAssumingyourthemeisnamedcorporateandhasa corporate.libraries.ymlfilewhichcontainsalibrarydefinitionnamedslideshow:
→/themes/mytheme/templates/mytemplate.html.twig:
{{attach_library('corporate/slideshow')}}
<div>Slideshowtemplatestuffgoeshere</div>...
Twig:AddingAssetLibraries
62
WorkingwithMultipleLanguages
AddingaNewLanguage
InstallthecoreLanguageModule.
GotoAdmin>Configuration>Regionalandlanguage(config/regional/language)toaddadditionallanguages.
EnablingContentTranslationInstallthecoreContentTranslationModule.
TheconfigurationsettingsofseveralEntityTypesnowhaveanadditionalLanguageSettingsfieldsetwhereyoucanenabletranslationandconfiguretranslationoptions.
ThetranslatableEntityTypesinclude:
nodes(contenttypes)customblockstaxonomytermsmenus
OncetranslationisenabledforagivenEntityType,allentitiesofthattypebecometranslatable.
AddtheLanguageSwitcherblock
AtthispointtheLanguageSwitcherblockhasbecomeavailableforyouuse.It'sagoodideatoaddittooneofyoursite'sthemeregionssoyoucanexperimentmoreeasilywithcontenttranslationandinterfacetranslation.
TranslatingContent
Youcanenableandconfiguretranslationsettingsoneachcontenttype'sconfigurationsettingspage.
TranslatablenodeshaveanadditionalTranslateLocalTasktabwhereyoucantrackthetranslationintoeachdefinedlanguage.
TranslatingTaxonomytermsYoucanenableandconfiguretranslationsettingsoneachvocabulary'sconfigurationsettingspage.
TranslatingBlocksYoucanenableandconfiguretranslationsettingsoneachcustomblocktype'sconfigurationsettingspage.
TranslatingMenusYoucanenableandconfiguretranslationsettingsoneachmenu'sconfigurationsettingspage.
WorkingwithMultipleLanguages
63
EnablingInterfaceTranslation
InstallthecoreContentTranslationModule.
AtAdmin>Configuration>RegionalandLanguage>UserInterfaceTranslation(/admin/config/regional/translate)youcanprovidecustomstringtranslationsorimport .potranslationfilesdownloadedfromhttps://localize.drupal.org.
Onhttps://localize.drupal.org:
FindandclickthelanguageforwhichyouwanttodownloadthetranslationsClickontheOverviewtabClickontheDrupalcoreDownloadlinkforDrupal8todownloadthe .pofile
Importthe .pofileatAdmin>Configuration>RegionalandLanguage>UserInterfaceTranslation/>Import(/admin/config/regional/translate/import).
LanguageDetectionandSelection
Wheneveryouloadapage,Drupalneedstodecidewhichlanguageisusedtodisplaypageelements(primarilytextprovidedbymodules,suchasfieldlabelsandhelptext).
ItdoessobasedonthetheLanguageandDetectionsettingsatAdmin>Configuration>Regionalandlanguage>Detectionandselection(config/regional/language/detection).
WorkingwithMultipleLanguages
64
WritingCustomMigrationsPresentation:https://gitlab.com/jpoesen/introduction-to-d8-migrations
Samplecode:https://gitlab.com/jpoesen/product_migration
WritingCustomMigrations
65
AdditionalResourceshttps://webtools.web.cern.ch/technologies/drupalhttps://test-d8-migration-trn1.web.cern.ch(trn1-trn10)https://www.drupal.org/docs/8https://api.drupal.org
AdditionalResources
66