How can I hide a div if menu is empty

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
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

Re: How can I hide a div if menu is empty

Post by paulbaker »

I would attempt to resolve this by creating my own template based on minimal_menu and putting the div tags within the template, only showing them if there are menu items to show. Worth a try?
To copy System Information to the forum:
https://docs.cmsmadesimple.org/troubles ... nformation

CMS Made Simple Geekmoots attended:
Nottingham, UK 2012 | Ghent, Belgium 2015 | Leicester, UK 2016
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: How can I hide a div if menu is empty

Post by velden »

Another options is to use the smarty {capture} tag.

It is said to be less efficient though.

Make sure the Navigator template returns nothing (not even some spaces) if there are no menu items to show.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: How can I hide a div if menu is empty

Post by calguy1000 »

Though paul's answer is technically the best... this will also work (and is better than capture, which is slow).

{Navigator loadprops='0' template='minimal_menu' start_level="2" assign='tmp'}
{if !empty($tmp)}<div class="wrap">{$tmp}</div>{/if}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: How can I hide a div if menu is empty

Post by Rolf »

after assigning you get access to the Navigator parameters in your Core::Page template. So you can also do something like:

{Navigator loadprops='0' template='minimal_menu' start_level="2" assign='tmp'}
{if isset($nodes)}<div class="wrap">{$tmp}</div>{/if}
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Post Reply

Return to “CMSMS Core”