[SOLVED] IF-statement to show submenu / sidebar?

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.
Post Reply
johnkarlsson
Forum Members
Forum Members
Posts: 41
Joined: Thu Feb 25, 2010 9:06 am

[SOLVED] IF-statement to show submenu / sidebar?

Post by johnkarlsson »

Hey,

Not sure if this is posted right. Move it if not.

So, heres the thing. I have two sidebars.

Image

As you see, theres one called "Navigera" and one called "Just nu".


So what I want to do now is if the page contains subpages it should display "Navigera" else
it should just show the "Just now" sidebar.

Example,

Contact
 - Find us
 - Mail us

This example would show both "Navigera" and "Just nu".

And the "Home" / "Hem" would just show "Just nu".

Sorry if this is messy, here comes the code.

Code: Select all

<div id="sidebar">
			<ul>


				<li>
					<h2>Navigera</h2>
					{menu template='zionnarrows : minimal_menu'  start_level='2' collapse='1' number_of_levels='3'}
				</li>
				
				<li>
					<h2>Just nu</h2>
					<ul>
						<li>Weather and stuff,</li>

					</ul>
				</li>
			</ul>
		</div>
		<!-- end #sidebar -->
Last edited by johnkarlsson on Tue Dec 07, 2010 4:39 pm, edited 1 time in total.
uniqu3

Re: IF-statement to show submenu / sidebar?

Post by uniqu3 »

In one of my templates i wanted something similar, with a difference that i wanted to disable whole sidebar, so maybe this could help you.
Install CGSimpleSmarty module.

Code: Select all

{if $cgsimple->has_children() || $cgsimple->get_parent_alias()} 
<li>
  <h2>Navigera</h2>					
  {menu template='zionnarrows : minimal_menu'  start_level='2' collapse='1' number_of_levels='3'} 				
</li>{else} 
<li>					
  <h2>Just nu</h2>					
    <ul>						
      <li>Weather and stuff,</li>					
    </ul>				
</li>{/if}
 
But if you want to hide only menu and have Just nu always visible you should simply do this:

Code: Select all

<div id="sidebar">
			<ul>


{menu template='zionnarrows : minimal_menu'  start_level='2' collapse='1' number_of_levels='3'}
	<li><h2>Just nu</h2>
					<ul>
						<li>Weather and stuff,</li>

					</ul>
				</li>
			</ul>
		</div>
The Navigera and closing should go in your MenuManager template. This way Just nu is always visible and Sublevel menu only if there are children.
Last edited by uniqu3 on Tue Dec 07, 2010 4:15 pm, edited 1 time in total.
johnkarlsson
Forum Members
Forum Members
Posts: 41
Joined: Thu Feb 25, 2010 9:06 am

Re: IF-statement to show submenu / sidebar?

Post by johnkarlsson »

Great!

Exactly! Only one thing. I didnt really get that part with the Menu Template.
I putted everything into the Layout -> Template and now when theres children
it doesnt show the "Just nu" part.

Been working too much lately, a bit lazybrainer right now.

thanks again
johnkarlsson
Forum Members
Forum Members
Posts: 41
Joined: Thu Feb 25, 2010 9:06 am

Re: IF-statement to show submenu / sidebar?

Post by johnkarlsson »

Solved it, maybe the same way you thought.

I simply put the IF-ending right after the {else}, this way Just Nu always shows. No matter what.

Thanks alot Uniqu3. Love your work (themes etc)!
Post Reply

Return to “CMSMS Core”