• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: Have an empty/blank menu display static text?
PostPosted: Tue Jun 06, 2017 3:12 am 
Offline
Power Poster
Power Poster

Joined: Thu Apr 15, 2010 12:27 am
Posts: 272
Location: Georgia
I have a menu item within my page that links to some specific pages as they are activated. However, before the first page is activated, the website is a little missing on that page. Is there a way to display some text like 'no pages active yet' ? Here is my navigator template code below. I assume I need to add an {else}<span>no pages active yet</span> or similar somewhere, but haven't figured it out. Any ideas?

Thanks

Code:
{function name=sub_menu depth=1}{strip}
  {foreach $data as $node}
    {* setup classes for the anchor and list item *}
    {assign var='aclass' value='button'}

    {if $node->current}
      {* this is the current page *}
      {assign var='aclass' value=$aclass|cat:'active'}
    {/if}

    {* build the menu item node *}
    {if $node->type == 'sectionheader'}
      <li class='sectionheader'><span>{$node->menutext}</span>
        {if isset($node->children)}
          {sub_menu data=$node->children depth=$depth+1}
        {/if}
      </li>
    {else if $node->type == 'separator'}
      <li class='separator'><hr class='separator'/></li>
    {else}
      {* regular item *}
        <a class="{$aclass}" href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if} aria-label="{$node->menutext}">{$node->menutext}</a
        {if isset($node->children)}
          {sub_menu data=$node->children depth=$depth+1}
        {/if}
    {/if}
  {/foreach}

{/strip}{/function}

{if isset($nodes)}
{sub_menu data=$nodes depth=0}
{/if}


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Have an empty/blank menu display static text?
PostPosted: Tue Jun 06, 2017 12:57 pm 
Offline
Dev Team Member
Dev Team Member

Joined: Mon Nov 28, 2011 9:29 am
Posts: 2722
Location: The Netherlands
Not exactly clear as how it should work but perhaps you can try:

Code:
....
{/strip}{/function}

{if isset($nodes)}
{sub_menu data=$nodes depth=0}
{else}
no pages active yet
{/if}


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Have an empty/blank menu display static text?
PostPosted: Tue Jun 06, 2017 1:04 pm 
Offline
Power Poster
Power Poster

Joined: Thu Apr 15, 2010 12:27 am
Posts: 272
Location: Georgia
Thanks. I had given that a try and just tested again with a copy/paste of your code (in case I had a typo in my example) but it doesn't output anything onto the page. Still just blank?

also: for the thread, I saw there's a typo on my closing </a tag. this was fixed adding the >.

edit: Any other ideas on how to display text when the menu is empty? Or maybe do I need to not do it within the navigator template, but within the page content instead where the menu is called? can that be done/easier?


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Have an empty/blank menu display static text?
PostPosted: Tue Jun 06, 2017 1:35 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Fri Dec 09, 2005 12:36 pm
Posts: 193
Location: Marlow, UK
Can you use count? Something like

Code:

{if isset($nodes) && $nodes|count gt 0}
 {sub_menu data=$nodes depth=0}
{else}
 nothing to see here.
{/if}



Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: [solved] Re: Have an empty/blank menu display static text?
PostPosted: Tue Jun 06, 2017 3:01 pm 
Offline
Power Poster
Power Poster

Joined: Thu Apr 15, 2010 12:27 am
Posts: 272
Location: Georgia
Thanks for the idea, I had not tried that one. It didn't work on first attempt, but then I realized my page alias had changed, so the menu wasn't showing what it should show anyways. Once I fixed that in my page content, then added
Code:
&& $nodes|count gt 0
to the navigation menu, the else statement now display if no pages are active!

Thanks all for the help! Excited to have this to be able to deploy in other scenarios as well to still have content when none exists yet


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: Have an empty/blank menu display static text?  Topic is solved
PostPosted: Tue Jun 06, 2017 5:55 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 7791
Location: Fernie British Columbia, Canada
Use: {if !empty($nodes)} ... it's simpler and faster.

_________________
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.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: [solved] Re: Have an empty/blank menu display static text?
PostPosted: Tue Jun 06, 2017 5:59 pm 
Offline
Power Poster
Power Poster

Joined: Thu Apr 15, 2010 12:27 am
Posts: 272
Location: Georgia
thanks @calguy1000 . made the update and working great


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting