Page 1 of 1

Making pages that dont appear in menus

Posted: Thu Jun 28, 2012 11:36 am
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:

Re: Making pages that dont appear in menus

Posted: Thu Jun 28, 2012 5:01 pm
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. :)

Re: Making pages that dont appear in menus

Posted: Thu Jun 28, 2012 6:27 pm
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

Re: Making pages that dont appear in menus

Posted: Fri Jun 29, 2012 6:23 am
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 :)

Re: Making pages that dont appear in menus

Posted: Tue Sep 18, 2012 3:35 am
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.

Re: Making pages that dont appear in menus

Posted: Fri Oct 30, 2015 4:11 pm
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!

Re: Making pages that dont appear in menus

Posted: Thu Nov 05, 2015 1:29 pm
by oldteacher
Sad that such a great and simple CMS would die...

Re: Making pages that dont appear in menus

Posted: Thu Nov 12, 2015 9:51 am
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).

Re: Making pages that dont appear in menus

Posted: Wed Dec 16, 2015 10:58 pm
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.