Making pages that dont appear in menus

Post Reply
Paul
Posts: 4
Joined: Thu Jun 28, 2012 11:22 am

Making pages that dont appear in menus

Post by Paul »

Here's a very simple change to function displayMenu in index.php that allows you to create pages and prevent them from appearing as a menu item:

Code: Select all

   function displayMenu($stags,$etags)
   {
	   global $menu;
	   
	   $mlist = explode("<br />",$menu);
	   $num = count($mlist);

	   for($ix=0;$ix<$num;$ix++)
	   {
		   $page = trim($mlist[$ix]);
		   if(!$page) continue;
		   if (strncmp($page, "[menu]", 6) == 0 ) {
				$page = substr($page, 6);
				echo "$stags href='$page'>$page $etags \n";
			}
	   }
   }
If you want a page to appear in the menus insert [menu] before it's name, for example:

[menu]Home
[menu]Example
HiddenPage

To access a page that doesn't have a menu entry either use it's URL directly in your browser:

yoursiteaddress/HiddenPage

or use html to link to it from any page:

<a href="yoursiteaddress/HiddenPage>Link to hidden page</a>

It's not particularly elegant way to achieve hidden pages but at least it adds only a few bytes to the code! :D

Disclaimer: I know next to nothing about php so if this introduces other issues - don't blame me!! :lol:
xss
Posts: 22
Joined: Thu May 26, 2011 9:07 pm

Re: Making pages that dont appear in menus

Post by xss »

Hello Paul,

nice idea, thank you. :)

Though, to make WonderCMS remain as easy as possible to manage for someone who doesn't read instructions and manpages in the first place, and to not suddenly and somewhat drastically change the basic way of how things work, I think we should probably make it work the other way round like so:

Home
Example
[nomenu]HiddenPage

So, only when the entry has the given prefix, it would not be shown in the navigation. After all, the box where you enter the entries is there to make new menu items or pages, so no reason to make that basic feature more complicated.

The code for that is almost the same, minus the subdtr() call:

Code: Select all

function displayMenu($stags,$etags)
       {
          global $menu;
          
          $mlist = explode("<br />",$menu);
          $num = count($mlist);

          for($ix=0;$ix<$num;$ix++)
          {
             $page = trim($mlist[$ix]);
             if(!$page) continue;
             if (strncmp($page, "[nomenu]", 8) != 0 ) {
               echo "$stags href='$page'>$page $etags \n";
             }
          }
       }
So, let's see what others think. :)
¿ן ʇ,uop 'spɹɐʍʞɔɐq ןןɐ ʇı ʇoƃ ן 'ɹɐǝp ɥo
Paul
Posts: 4
Joined: Thu Jun 28, 2012 11:22 am

Re: Making pages that dont appear in menus

Post by Paul »

Or require [menu] or [nomenu] for each page?

[menu]Home
[menu]Contact
[nomenu]Private Stuff

To reduce the risk of user error by mis-spelling I suppose the menu 'tag' could also be reduced to a single non-alphanumeric character...

*Home
*About
Hidden

or even +/- to indicate inclusion/exclusion...

+Home
+Search
-Secret

Just ideas :D
Paul
Posts: 4
Joined: Thu Jun 28, 2012 11:22 am

Re: Making pages that dont appear in menus

Post by Paul »

I knew there was something else bugging me about this and why I chose to use [menu] in the first place...

As users would most likely want to link to hidden pages and less likely to link to pages that are already on the menu it would mess up the urls - a [nomenu] page would be something like:

www.yoursite/[nomenu]Hidden

Stripping [menu] from the page name before labelling the links obviously works better :)
Tim
Posts: 3
Joined: Tue Sep 18, 2012 3:30 am

Re: Making pages that dont appear in menus

Post by Tim »

Paul wrote:As users would most likely want to link to hidden pages and less likely to link to pages that are already on the menu it would mess up the urls - a [nomenu] page would be something like:

http://www.yoursite/[nomenu]Hidden
I don't understand how this would mess up the URLs when you would be manually inserting a link to the "hidden" page as <a href="HiddenPage">HiddenPage</a> or <a href="http://www.your.site/HiddenPage">HiddenPage</a>. From just reading this thread and not trying to put it into use, adding a delimiter to specify which pages not to include in the menu seems to make the most sense.
oldteacher
Posts: 8
Joined: Fri Oct 30, 2015 4:09 pm

Re: Making pages that dont appear in menus

Post by oldteacher »

Realize this is very old thread but does it still apply?

Do not seem to find any such code in index.php to modify?

Thanks!
oldteacher
Posts: 8
Joined: Fri Oct 30, 2015 4:09 pm

Re: Making pages that dont appear in menus

Post by oldteacher »

Sad that such a great and simple CMS would die...
User avatar
wiz
Posts: 749
Joined: Sat Oct 30, 2010 12:23 am

Re: Making pages that dont appear in menus

Post by wiz »

Hello oldteacher, this does not apply for the latest version anymore.

WonderCMS isn't quite dead, and it will probably live forever, only the pace/speed of development is questionable (as you can see in the other posts, I've explain numerous times).
oldteacher
Posts: 8
Joined: Fri Oct 30, 2015 4:09 pm

Re: Making pages that dont appear in menus

Post by oldteacher »

rob wrote:Hello oldteacher, this does not apply for the latest version anymore.

WonderCMS isn't quite dead, and it will probably live forever, only the pace/speed of development is questionable (as you can see in the other posts, I've explain numerous times).

Hi Rob.

Nice to hear for sure. WonderCMS is perfect for younger students. They can use to create simple "about me" sites on local network at school

If I could figure out how to add pages without them appearing in menu and also get an editor like CK, NiceEdit or another which allow image manger would be so happy.

Thanks for the reply.
Post Reply