Menus Primary and Secondary Links

There are three default menus that can be configured in Drupal. The navigation menu is the one we have been using up to now and is the standard menu system for traversing all the functionality the site administrator needs. At some point you might want users to have quick access to several main sections of a site, in which case the primary links may be configured to provide this feature. For less important links, generally stuff like About us or Terms of use pages, Drupal provides the secondary links menu.

Clicking on Menus under Site Building in the Administer section (or double-clicking for DHTML menu users) provides access to the navigation, primary and secondary link dialogs as well as the Add menu and menu Settings pages:

Menus Add menu settings

Mifnui are J colli- r.Li'jn Of links iniinu Hems) tfi ^¿vtgate a web^JCt Tine menu* currently available on your si(f in? displayed helov.'. Select j tltenu frgni tills PiSt to manage Ets menu (temS-.

Navigation

Tfhe navigation menu is provided bv Drutial and is th* mam interactive m&nu for any site, it is usually the onfy menu that contains personalized lirfltsfor authentitated users-, and is often not even visible to anonymous users.

Primary links

Pnmary links are often used at Hie theme ¡aye? to show the major sections of a sit?- Atypical representation for primary links would he tabs dlono the top-

Secondary ¡Irtlts

Secondary Imks are often used /or pages like legal notices, contact details, and other secondary navigation "terns that play a lesser ro-le than pnmarv links

Basic Functionality

If at some point, the default menus are not sufficient for your purposes, adding a new menu is quite easy:

MenitS List menus Settings

Enter the name for your new menu. Remember to enable the newly created block in the blocks administration page.

Menu name:

quicklrnks

Th« mji;hlri»-r«ad»bk nam» fcf this mtnu. ThiJ tout ™i| bfl UJfld für CO" strutting th» URL of tK« fnwfiv p!i*rV3iiv = forthii imirtu. This nim* mmit TO^tftin only lo^t^ns* ifltt^r*. nyrTLbir-t. hyph+fil. tnj iYiuJ! bfl Lifiiqu*-

iQjiCk Links_.

Description:

A goläection of the most popular links

Any added menu will now be available to work with in the Menu section just like the defaults. Remember that the new menu will not show up until you tell Drupal where it should be displayed in the Blocks section of the Site building menu.

The Settings options, shown in the following screenshot, can be a little more dif cult to fathom initially.

Menus LiStinwui Wd n:»nu I

Thf iWv iHOwf VHto-O} tf imkf im

■Utonng i&irr^ Tto roSijniHd WfirtP Htt W* dsfaulc ^ 4 fi*1« mk »¡L DO added rjrl.-.iilt iim-iiu Tor cuntniur.

| t'jjvtgjbon v ftibi ! - " ■ .l^fpull r- r-^n.i n^ui1 ■ >1 ip-* ^l-irag i■■■!>..

'.iiiirif l iir llkl' prim my IliiVt:

! PftfTiiraf \nfcj v

Hl-ff feNtsM !■• ^'iilii+d mr IJ^i firtffi** IV Ihp n^iwi.Ur* liiikv.

I i'kC bv rs*d mp i ■ i»"iir|f ■ iVi^ g r^nu iiti i mi ta* -pm—mf -p* i (tvwHr^«^ i>±j j f c-j fa ih»

The Default menu for content option specifies where links that are added during content creation (for example, when creating an About us page) will be added. It's basically a shortcut method of adding new content to the menu because it saves you from having to post some content, find the relative path (i.e. http: //localhost/ drupal/forum), and then add that to the menu manually—although, we discuss this process in a moment.

The next few options are interesting because they control where the links displayed in a theme's primary and secondary links menus are drawn from. For each of these you can select either to show the navigation menu, primary or secondary links, or not to show the menu at all. As a quick exercise, set the Source for the primary links to Navigation and click Save configuration. You should find that the Navigation menu items are now displayed in the Primary links menu, like this:

y

vv saoi-i^

■-•iOdU'-i-CH.»'-

¿dnunift*!

ILlO^ii

localhost

< ■■ ■ ■ JtilhunA-i

-..li .

4 1KflCOri

Adminiittr

COTbflFE rr.iir.^ij+tfiriflrii ifin b^-Kinrj ° ftiQCkf Monus

Navigation ^mafv trts aa-rcndjf'r httfcs d6

4 1KflCOri

Adminiittr

COTbflFE rr.iir.^ij+tfiriflrii ifin b^-Kinrj ° ftiQCkf Monus

Navigation ^mafv trts aa-rcndjf'r httfcs

Menus

LiTt mfiin.-: "iild nwinii n-ro aap*«gur airon cpLon j Pioto b«n ijwDd

Thi IWIU maduiB -fltowi sn-iha-fly if «awn Of fr^nu M-i n ch* dw^rt «utfwwfl foms Tiift rcLlowrTtgi opinnn ic-nct Bh* ablaut rr»irYJ in which a no* link w4J b+ Jdrtod

Di-f j'jll ntnrau fof cotftciit:

^¿a^mjjban v iMiiM.i lii I— ih* >1*1 ivh ..I ir.. rw*fnj np|i*oi wt l*«l« «mttMHtftfll ift'il*.

isn'iinr For Shu jirinHH-y

D*ii rt ■1.il aliu-i'-t ■ CHSt'-ip+il P^irrii^i k-.t J.

Basic Functionality

It's a bit confusing to picture what is going on before we have even looked at the primary links in any detail, so we'll clarify this in a moment. For now ensure that you reset the Source for primary links option to Primary links and click Save configuration.

Go back to the List menus option and select Navigation to bring up the standard menu overview dialog. From here, you can add, edit, enable, disable, or, in some cases, delete items as well as determine whether or not items should be expanded in the menu by default. In addition, items that are enabled or disabled will subsequently display a reset option that turns any configuration back to their defaults:

Search (his site:

Navigation

Atldrtim

Edit menu

I Suich I

To rearrange menu ¡terns. grab a drag-and-drop handle under

the Menu

nf4good

jism colurwi arm dra g the items (or flnoup ai items) to. a new loiation in the

btoss

bit. [Grab a handle by didung and holding til.1 mouse whde ever .1

COmUOPt riDS hmuau

handle icon,) fememter that your changes v<jII not be i-aved until you dick

the ccpiiftirdii&fi button at th* bottom af Hie page.

Hy bttbijfd

PoJls sisrth

Hfiitu itein

£nabred

fxpanifed

tJpermitnis

-ir Qlggp (tfMblOtf

flit

Create ocnteni

+ My bios

B

in

flirt

AdminHUr

CQHIiHJ}? tl[>S (¿lilDliJ)

Content msn-agemenl

+ forums (disahled)

Ft

■edit

Comments

My account

W

G

■edit

Content

-t POlfi {disabled)

■fitfit

Contwit typei

+ (ic^bltdj

«at

Forums Pu5t gittwngs

4- owfte eomtifli

m

B

edit

ftss publishing

BJog entrj

¡2

n

edit

'i-j>;gnrjmv

t Fonini topic

3

edit

Sir; bwldin.3

+ Pag?

m

B

edit

Blocks

4- Poll

E

n

«ft

It is important to note that adding a new module does not necessarily mean that it will be added to the Navigation menu. Revisit this page any time you add new features and want them to show up in the menus—bear in mind that some modules will do this automatically.

For the moment, let's not mess around with the Navigation menu, since it is possible to make some irretrievable changes that could cause a bit of hassle later down the line. Instead, let's look at how to build up the Primary links menu. Click on that option under Menus to bring up its overview page and then select Add item:

Primary links List items t ^ Edit menu

Menu settings

Path:

path thli m«TUj item linla lo. Thij tir. b« an lnt»rni[ Dnjjjal Oith iuc^

or in ■iitbarnol URL Iuc~ n: bttp. j! c-ry.. Er.ler link to tha front UJtgtj

Menu link title:

Home

Thi« I nk levL tarreipond>ng t; tfin «(aim that should appear In tHa nwiu, Description:

Return to the site's front page

The delcNntlOrt dilplh^fld wti*n bevftnrtj GVW * menu ll*fn.

SI Enabled

Meou it«mi that ar« net enabled wH net listed Jn in/ menu. Expanded

If nle<;-»i pn(J tliii m«nij itflm h»f chiidrQn. tfifl rr»nu Till ^.rv.uvT 4Kpkndcd.

Parent item:

Til« iniwrrun depth fer in itam and all hts thilirari >i f.-yad at 3 Soma «it'm

.( = rr: may net fci ivj I;: i if spr-j.-i.ti |f lelitt'np thflm 1his l.m.t,

Weight:

Optional- En rn*r»Ur the heavtor itemi w.lI jink and tti* Sightsr J*»nw b-a position^ n«arar the tap.

Basic Functionality

In this instance we are creating a new menu item that will take users back to the home page. The Description will be displayed as a tip whenever a user hovers their mouse over the link, so ensure you enter something succinct and helpful here. Since this link will not have any child links there is no point in selecting the Expanded option because there will be nothing to expand. The Parent item is of course set to Primary links, but modify this to the appropriate menu item depending on where in the menu you want it to appear.

Clicking Save adds this new link to the Primary links and it will be available to edit, disable or delete in the overview section. More importantly, looking at a page now should reveal the effect this has had:

fef j rr h

fef j rr h

SodttA Lhllilru fa fr n • j-njp Awiu i^mj [P JO $ il> jhj - ilHl-^iie- rtnluflw voidipi |h« Mf^iu m .■-■P/njv j-r:| |h »p t vrm ¡3>r.,je pi Cem*; tl! ■ r^Tri tof Jftwt if- Hi» Im( tf. ■ f,, ij-^ig (In. m.-n.-n w3.Jn Iri^.n-^ »

hflndk on'f Ha^tfnfa*- that tOlt dirq« ltdI not ta i-aiy-d und jgu tkd-

r.i:-s i-.trt J'yj itv" BHiOftn K fehsl tMKlH* fJ ih*

Poll

SodttA Lhllilru mfigOMj tYUjl tUTlfHIH 304

^cnimi

P.h hiitfi

Uqiiln

Primary linVs fa fr n • j-njp Awiu i^mj [P JO $ il> jhj - ilHl-^iie- rtnluflw voidipi |h« Mf^iu m .■-■P/njv j-r:| |h »p t vrm ¡3>r.,je pi Cem*; tl! ■ r^Tri tof Jftwt if- Hi» Im( tf. ■ f,, ij-^ig (In. m.-n.-n w3.Jn Iri^.n-^ »

hflndk on'f Ha^tfnfa*- that tOlt dirq« ltdI not ta i-aiy-d und jgu tkd-

r.i:-s i-.trt J'yj itv" BHiOftn K fehsl tMKlH* fJ ih*

r N ln'iOijqSj

Offlo-jrHafti

Poll

ProthiMr jH»I

Rjieni DiojpMl*

Hi SxjT Lilr.j ^YlJjMf IWlNl 41A.

Notice there is now a Home link at the top right of the page. This is where the primary links are displayed in the default theme, but different themes might make any number of changes to the Primary links menu (including not displaying it at all). Clicking on Home should take you straight to the default front page, as specified when the link was added.

Try to add another menu item to the Primary links to make sure you can add any target page at will. Since we have created a forum, let's add the forum front page to the Primary links (can you guess the target Path we should specify?):

Primary links

Menu settings

Path;

List items

Add item

Ed.it menu forum

I he - ¿rh rhu ricra Item liftkj teil. This zur- be an nlcmj! Drnp.nl path -Li=b il nedt/mdd cr in e^l^mal URL Juth ti btv:ffdtuisat.or$, Enter <HvnO to Jink to tha Front paga.

Menu link title:

Forums

Th* link text tor's sa-ondlnç Co thii item that ihù-iJd asses: in ths mariii, Description:

Go to the forums

Tha description d ii p-layfrrf v.li3n havering tv«r a nanL jtcm.

13 Enabled r-ltni> it«mi that *re net e 11 bled vwll ne-t be l.jted tn any menu. U Expanded

If selected and Its menu rtem ha* diildren. the menu villi alv-aya «spear tKpanderf,

Parent item:

The fn AJçilïiLLm dc^th far an item and all its. i". Idron I* r 1 :■: o d at Süma manu Itemf may not be availüdla aT paronti i' relucting [him would flKCe-ed this limit.

Weight:

Optional, tfi the menu, the heavier itemi vn.ll unk and tha liphte-r itemi wll tie positioned nearer the top.

f save

Basic Functionality

A good trick, hinted earlier, to locate the path needed for a menu item is to navigate to it directly and then cut and paste the relative path (i.e. everything in the URL after the root). For example, if we go to the forums on the site as it stands, the URL looks like this:

http://localhost/drupal/forum

The bold part is the relative path because http://localhost/drupal is the root folder (or homepage).

Now, you might decide that in addition to visiting the forum front page, you also want to add the containers to this menu so that people can go straight to their forum of choice.

After saving the forum primary link, go back to the Add item dialog and then add the new link as follows:

Path:

forum/9_

TTm pith this rr4rtJ m linki ta. Th-i can ba an -ntarnal £rupal pac- iy-:h ax -cdr/jdd cr a--, flytvmil URi. iucn ji mt.oty* Enter c^ntnJ^ (c Sink ta thfl

^rant page.

Menu link title:

¡Global warning

THa ImL- to LDTtiucndi^ bo thu rt«m that itidu'd appear In th-t cnonu.

Description:

¡Global warning

THa ImL- to LDTtiucndi^ bo thu rt«m that itidu'd appear In th-t cnonu.

Description:

ThH -d+lrripiitfl dlipli^Cid h-ivflrlftj BV*i 1 n((|u it«f".

E Enabled

¡■Innu itvmi tnat arc nGt«-nabled Mill fxit tin intid In any rr-.«nuj

ThH -d+lrripiitfl dlipli^Cid h-ivflrlftj BV*i 1 n((|u it«f".

E Enabled

¡■Innu itvmi tnat arc nGt«-nabled Mill fxit tin intid In any rr-.«nuj i— Expanded

[■ itieilfd md l+in it*rn hm thildt^ap "Jit mt-nv »JH »Ihbv« »pp«r wandatfi

Parent item:

th» ithkiirum d#pth h-r an tjm inc all ^-.ildra-n is fi^cd J 9, - i.-r.o t.c-li <Hm-i miv r.pt ha *uail*bl< if par^nli If i+|«clinc lh*m ujglIc mtri this limit.

Waiglit:

OpSionjili In th4 01«nu. the heavier lEwmi l'."II sink and tha lightov ifcorns will ba ¡pq-pib-pnad mar*r thm top._

Determining that forum/9 corresponds to the Global Warming container required a quick visit to the container that displayed http://localhost/drupal/forum/9 as the URL, and from there it is a simple matter to add this to the Path. Remember, that we want this link to be a child item of Forums within the Primary links, so the Parent item needs to be changed accordingly. Be careful here because you are able to select a parent item from any of the menus, so it is possible to choose the wrong one.

With that done, click Save and then take a look at the Primary links at the top right of the page:

ieare-h sw«* raitM

LiaffiiiJ

Market Force for Good

' i.i idli 1 l**in

hl—■ - ■ ■ !i-:c sj_u y »■ '"mw

Ii [lii-k

Frimaiv links r ^u.

Poll

L 5*3ldl 1

yrvu Ihluh rnv will fcc stcnvfi?

Defend ■ Hj* bï £> iWSjtllVJHlt 0

Bkxn

Cuiwutet rumiiii

Pifll

Saairti

7ü »airing? mûmj Kernt, pill a îI'îû .-ïj Jr hjr>dlD ür-dr^ r1- e ~'r 'i. (Mt tdumr. jml ij^ihricflic itr troua 4f ilt-mhi » J. rhi^itxjlwnnh.-Ort, (CiJÜ »lii-nfle b* dating »ni vrlitr hui s™^] un* -S hjrri- •ici.;-mal »oiir di ariQ?c h.£ rai M »vül! LTUÜ yüu tick

'j--: an* biiK^r il Ihr L-iStoni oi 11--: djg*"

MrftL rtt'fti f*dU*d i X| lird .MnriJI^.I,-:

+ ronmu föj 0

pd«

Recent blog posta

MI

crut* lurflvrtl

+ omijj1 v'.jitt. rjn ä<

«H (hielt;

iinwimr lonrorf m^n j jH>inr-iii mcduiinm grki MflUI

IIÙIIH- IlS

HÜ üdk'Ea

; ¿m^tpsfitummoin

Of course, Global Warming is not immediately visible because it is a child of Forums. Unfortunately, clicking on Forums takes you to the forums and does not expose the Global Warming link within the Primary links as you might expect—this is because Primary links do not display child links.

SHING

Basic Functionality

We have a trick up our sleeves though because we can set the Source for secondary links to Primary links. This means that the Secondary links are sourced from the children of Primary links, so when we click on Forums, Global Warming, as a child element of the Primary links, appears in the Secondary links:

Market Force for Good

Fdrurats Home uitiijji //annul D

If things are still not clear, then perform the following exercise to highlight the other side of the coin:

1. Go back to the menu Settings page and select Secondary links as the Source for secondary links.

2. Go to Secondary links and Add item, ensuring it is saved with <Secondary links> as Parent item.

Take note of the changes to the Secondary links while performing these steps—you should nd that any items added to the Secondary links show up as expected in the Secondary links area, underneath the Primary links. Changing the source back to Primary links will of course mean that Global Warming, or whatever other child links there are in Primary links, are displayed once more.

You are not constrained to stick with the conventional setup for these particular menus either. Head on over to the Blocks section of Site building and set the Primary links block to display in the Left sidebar (remember, there is also a DHTML version available if you prefer). With that saved, there is a new view of the Primary links menu complete with child links:

Priinaiy links

Alternatively, it is easy enough to display any of the menus you create manually in any area of the page by going to the Blocks page and specifying the desired region for the menu.

Chapter 3

Having the ability to create unlimited menus and display them anywhere is a very powerful feature. There are a multitude of different combinations to try out. For example, you might wish to create a content menu that contains a listing of all the different types of content on a site—blogs, forums, stories, polls, and have this as the primary links. Alternatively, you could create an entirely new menu and add this to the Header region by configuring it on the Blocks page.

0 0

Post a comment