SOLVED : Need to create a different submenu for each section of the site...how?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Eskymo

SOLVED : Need to create a different submenu for each section of the site...how?

Post by Eskymo »

Hi there

I'm new to this, but so far have managed to build a template fore every page of my site and sort out the primary navigation that runs along the top. I now need some guidance as to how to create my sub menus. In the dev site I built I created the menu's as styled lists, like so:

Code: Select all

<ul class="subnav">
	<li><a href="#">Services Home</a></li>
	<li><a href="#">IT Maintenance</a></li>
        <li><a href="#">Another Link</a></li>
	<li><a href="#">The Last Link</a></li>
</ul>
with this CSS code to style it:

Code: Select all

ul.subnav {
	text-align: right;
	margin: 0px 38px 0px 0px;
	font-size: 90%;
}

.subnav li {
	background: url(assets/subnav_arrow.gif) no-repeat right center;
	padding-right: 15px;
}
How would I go about creating a generic {menu} item that could be placed within my template pages. Or would I have to craete a different {menu} item for every section of the site? I need the subnavs to be updateable easily by the client, but am I right in thinking that if she adds a new page and specifies the parent page then it will automatically be added to the subnav list?

I found the generic sub menu in the documentation (http://wiki.cmsmadesimple.org/index.php/User_Handbook/Admin_Panel/Layout/Menu_Manager#Generic_sub-menu) and wondered whether I could use that.

Thanks

E

p.s. Is it best practice to create all your sub pages first and then do your subnv or doesn't it matter?
Last edited by Eskymo on Wed Nov 07, 2007 9:20 am, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Need to create a different submenu for each section of the site...how?

Post by Dr.CSS »

You don't need that UDT for a second menu that shows the children of the clicked top nav/menu...

Look in menu managers Help to see how to do it easily... start level is the key and the ul id is set in a new menu template in menu manager...
Eskymo

Re: Need to create a different submenu for each section of the site...how?

Post by Eskymo »

Thanks for taking the time to reply to my query Mark, but I'm not quite sure what you mean.

My subnavs will be completely separate from my primary navigation - in location on the page and a separate is required to place them in the left hand column of my site. I presumed that because of this, I would need to create a new {menu} item of some sort.
User avatar
lollipop27
Forum Members
Forum Members
Posts: 237
Joined: Wed Sep 12, 2007 4:09 pm

Re: Need to create a different submenu for each section of the site...how?

Post by lollipop27 »

i think you need this

Code: Select all

{menu template='simple_navigation.tpl' start_level='2' collapse='1'}
so the sub menu will start from the second level, thats what mark meant.
Eskymo

Re: Need to create a different submenu for each section of the site...how?

Post by Eskymo »

Ok, thanks for that. I've added that and created a sub page for one section and it does create a subnav in the correct location. But it's not styled the way I want it - but I can figure that out I'm sure...my next question is the formatting. How do I get rid of the numbering as at the moment the subnav appears like this:
2.1: IT Maintenance
I would prefer it to just say 'IT Maintenance'

Amy ideas?
User avatar
lollipop27
Forum Members
Forum Members
Posts: 237
Joined: Wed Sep 12, 2007 4:09 pm

Re: Need to create a different submenu for each section of the site...how?

Post by lollipop27 »

say to you styleheet:

dfn{
    display: none;
}
Eskymo

Re: Need to create a different submenu for each section of the site...how?

Post by Eskymo »

cheers for that - will do.
Eskymo

Re: Need to create a different submenu for each section of the site...how?

Post by Eskymo »

Yep - that works a treat! and I've managed to figure out how to style the subnav the way I want it too.

Thanks for all the help! I'm getting there, slowly but surely.

Next = news! arrrrgh!  ;D
Eskymo

Re: Need to create a different submenu for each section of the site...how?

Post by Eskymo »

ooops going a bit to quick for myself there...I've just encountered a problem with the subnav.

It looks fine on the page I've applied it:
http://www.techsinthecity.co.uk/devsite/index.php?page=services

but when I click on it to link to the subpage I've created
http://www.techsinthecity.co.uk/devsite/index.php?page=itmaintenance

the main nav button active state is poistioned below the primary nav where it shouldn't be and I also get the following error where the subnav should be...
string(70) "Smarty error: unable to read resource: "globalcontent:security_subnav""
which is odd as I did have a globalcontent thing in place initially but I removed that and replaced it with

Code: Select all

{menu template='simple_navigation.tpl' start_level='2' collapse='1'}
on both the services page and the services subpage.

I'm confused...is there a caching problem? Is there a way to clear the cache if that's what's causing the issue?

Also - looking at the source of the generated HTML page I see that the subnav is actually placed within the primary nav - is this normal or is that what is causing the problem.

I'll see if I can find a cache thing somewhere and try that...
User avatar
lollipop27
Forum Members
Forum Members
Posts: 237
Joined: Wed Sep 12, 2007 4:09 pm

Re: Need to create a different submenu for each section of the site...how?

Post by lollipop27 »

Well,

do you have different templates? perhaps some sites still use different templates.

it seems to me, that you have quite an confusing amount of divs and tags.... perhaps cleaning helps


there is a cache in you browser, and the cmsms in the global settings, "clear cache"


perhaps that helps...
Eskymo

Re: Need to create a different submenu for each section of the site...how?

Post by Eskymo »

yes the main services page and the services sub page are using different templates, but the

Code: Select all

{menu template='simple_navigation.tpl' start_level='2' collapse='1'}
code is in place in both templates.

I may have a lots of divs but the structure is fine - maybe I have too many tags as I'm new to CMSMS and overcomplicating things, but this shouldn't affect the subnav getting that error, surely?

Clearing the cache of the browser had no effect and I've been reading worrying things on this forum about clearing the cache for the CMS and worried my site will disapper...but it's worth a try and I hope it doesn't cause any more problems.

edit - nope. clearing the CMS cache has had no effect on this problem. Does anyone have any ideas why the subnav on my subpage is throwing a wobbly?
Last edited by Eskymo on Tue Oct 30, 2007 9:03 pm, edited 1 time in total.
Eskymo

Re: Need to create a different submenu for each section of the site...how?

Post by Eskymo »

ok - so the issue was a cahing problem - I deleted the subpage I created and started from scratch and created a new one and the subnav now works ok - apart from the fact it goes bold and grey on the actual subpage, not sure why.

But I'm still getting a problem with the primary navigation image active state sliding down to sit directly below the primary nav...see here:
http://www.techsinthecity.co.uk/devsite/index.php?page=asubpage

is there any way to fix this? I can't figure it out. the only thing I can think of is that the for the subnav is getting slotted into the of the primary nav...but this doesn't affect the primary nav on the main services page. very weird.
Last edited by Eskymo on Tue Oct 30, 2007 9:17 pm, edited 1 time in total.
User avatar
lollipop27
Forum Members
Forum Members
Posts: 237
Joined: Wed Sep 12, 2007 4:09 pm

Re: Need to create a different submenu for each section of the site...how?

Post by lollipop27 »

well, I dont really understand you...

can you please paste the code of you template...


did you insert that in the top navigation??

number_of_levels='1'
Eskymo

Re: Need to create a different submenu for each section of the site...how?

Post by Eskymo »

the problem is happening with the subnav occuring within the primary nav

Code: Select all

<li id="services"><a href="http://www.techsinthecity.co.uk/devsite/index.php?page=services" title="Services"> <span>Services</span></a>

<ul>
<li id="asubpage"><a href="http://www.techsinthecity.co.uk/devsite/index.php?page=asubpage" class="active" title="A Sub Page"> <span>A Sub Page</span></a></li></ul>

</li>
as the subnav occurs between the primary nav tags for some reason it forces the nav image down. Not sure why this isn['t causing a problem on the main page though actually, so maybe that's not the issue. the template code for the subpage is as follows:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<__html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title>{sitename} - {title}</title>
{* The sitename is changed in Site Admin/Global settings. {title} is the name of each page *}

{metadata}
{* Don't remove this! Metadata is entered in Site Admin/Global settings. *}

{stylesheet}
{* This is how all the stylesheets attached to this template are linked to *}

</head>

</__body>
<div id="wrapper">
<div id="innerwrapper">

<div id="header">
{global_content name='header'}
</div>

{* Start Content *}
<div id="contentservicessub">

<div class="column1">
<img src="uploads/images/assets/subnav_services.gif" alt=" " width="162" height="53" />
{menu template='simple_navigation.tpl' start_level='2' collapse='1'}
</div>

<div class="column2">
{content block="column2 H1 Heading"}
{content block="column2 P Introduction"}
{content}
</div>

<div class="floatclearleft"></div>

</div>

<div id="footer">
{global_content name='footer'}
</div>

</div>
</div>
<div id="base"></div>
<__body>
</__html>
and the code for my primarynav - which is pulled in via the {global_content name='header'} tag is:

Code: Select all

{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}
{repeat string="<ul>" times=$node->depth-$node->prevdepth}
{elseif $node->depth < $node->prevdepth}
{repeat string="</li></ul>" times=$node->prevdepth-$node->depth}
</li>
{elseif $node->index > 0}</li>
{/if}

{if $node->current == true}
<li id="{$node->alias}"><a href="{$node->url}" class="active" title="{$node->menutext}"> <span>{$node->menutext}</span> </a>

{else}
<li id="{$node->alias}"><a href="{$node->url}" title="{$node->menutext}"> <span>{$node->menutext}</span></a>

{/if}

{/foreach}

{repeat string="</li></ul>" times=$node->depth-1}</li>
</ul>
{/if}
let me know if you need any moer info. Thanks for trying to help - this is doing my head in...but it is late, so that's understandable.
User avatar
lollipop27
Forum Members
Forum Members
Posts: 237
Joined: Wed Sep 12, 2007 4:09 pm

Re: Need to create a different submenu for each section of the site...how?

Post by lollipop27 »

ok

so. why do you use global content?

the easiest to do this is:

use "simple_navigation" in your menumanager.... !

or create a new one, and paste your code into it (the one that is standing in your global content)


then add this

Code: Select all

{menu template='simple_navigation.tpl' number_of_levels='1'}
into your template inside the header



the good thing is the "number of levels".... so thet the subpage is not shown (thats what causes you problems)

and I don't know if your code can do that (I'm not that good in PHP...  ::) )


Try to use menumanager.... its cool.


hope this helped
Locked

Return to “CMSMS Core”