Show menu only on specific pages

flip

Thank you for all the suggestions. I hard-coded several of them (Page IDs, URL parameters in htaccess error pages, etc.) and it works great!

Argos

#10
Quote from: flip on August 02, 2012, 05:48:12 AM
@Argos: I show the main menu on the error page as well like Zalando does but I don't want to show my sub-menu on these pages.

Try this:

<?php 
if (PAGE_ID!=0) { 
echo 
"your-menu-call-here";
}
?>


Or this:

<?php 
if (PAGE_ID>0) { 
echo 
"your-menu-call-here";
}
?>


Not tested...
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

marmot

Hi,

Quote from: flip on August 02, 2012, 05:41:12 AM
It's not redirecting to the error pages. The error pages are opened under the link which doesn't exist.
ok, had a small error in my thoughts ;). Besides the possibilities mentioned above it would be possible to do the redirect this way:ErrorDocument 404 /en/error/404.php?redirect=1 and your existing condition for the menu call has to be extended by:
&& !isset($_GET['redirect'])

regards

flip

@Argos: I show the main menu on the error page as well like Zalando does but I don't want to show my sub-menu on these pages.

flip

Hello Marmot,

I'm using simple htaccess rules:
ErrorDocument 400 /en/error/400.php
ErrorDocument 401 /en/error/401.php
ErrorDocument 403 /en/error/403.php
ErrorDocument 404 /en/error/404.php
ErrorDocument 500 /en/error/500.php

It's not redirecting to the error pages. The error pages are opened under the link which doesn't exist.

Philip

marmot

Hi,

Quote from: flip on August 01, 2012, 07:07:49 PM
There is no redirect to:
http://www.zalando.de/error404.html
that's fine but how (from the programmers view) is the call for the error page done in your case?

regards

Argos

Quote from: flip on August 01, 2012, 07:07:49 PM
Regarding the htaccess error page: It's not a redirect but the error page opens under the URL which you opened. Amazon and Zalando work similar:
http://www.zalando.de/jack-jones-clark-original-jeans-dark-dim-ja222x016-953.html

And they do show the menu  :roll:
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

flip

Hello,

Many thanks for the ideas. I will try them.

Regarding the htaccess error page: It's not a redirect but the error page opens under the URL which you opened. Amazon and Zalando work similar:
http://www.zalando.de/jack-jones-clark-original-jeans-dark-dim-ja222x016-953.html

There is no redirect to:
http://www.zalando.de/error404.html

Philip

marmot

Hi,

QuoteWhat I am using right now is a hardcoded menu which only shows up when the URL matches specific criteria, e.g. ends with /prices.php. The issue is that the menu is also shown on custom htaccess error pages when you open a not-existing URL which also ends with prices.php. I don't want to show the menu on these error pages.
it's hard to imagine why this doesn't work as the url becomes a new one when redirected. Maybe you can give more information on how redirection and menu creation is done and show an example.
QuoteDo you have a better solution for showing / hiding a sub-menu on each separate page or do you have any suggestion how to avoid showing the menu on the htaccess error pages even though the URL matches?
- use page id instead of url to recognize the need of menu
- check url also against table pages to see if page exists
- use banner module
- if pages with or without menu are all on same menu levels you might try to use sm2 call (start and end level) to show/hide menu

regards

Argos

You can create a hidden menu block and assign pages that menu if you don't want to show the menu. So add a line like

$menu[4] = 'Hidden';

and set the menu to "Hidden" in the page Settings.

I tried it and it works fine, except for 1 thing: it only hides all other pages in the menu, but it still shows the current menu item. So if you hide the page "Products", the site shows a menu with only "Products". But the menu graphics (if you use those) will still be visible. So this solution hides the menu entries, not the menu itself. But it can be useful nevertheless.

Another solution is to hide or show the complete menu according to page ID. Something like this in your template will work:

<?php 
if (PAGE_ID==24 PAGE_ID==30 PAGE_ID==45 PARENT == 24 PARENT==30 PARENT==45 ) { 
echo 
"your-menu-call-here";
}
?>


That way the menu will only show up on pages with ID 24, 30 and 45, and on their child pages. If you want to hide them, instead of show them, use != instead of ==.
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

flip

Hello,

I am using the menu2 module and included the menu in the template. I would like to show the menu only on specific pages. The options I came up with:

- Create a separate template: It would mean a lot of more work because I need to keep up-to-date another template just to have one with and the other without sub-menu.
- Use Droplets: Add the menu code to a droplet and add it only to the pages when needed. I haven't tested it but it's also not s9o good for me because then I need to create new placeholder sections

What I am using right now is a hardcoded menu which only shows up when the URL matches specific criteria, e.g. ends with /prices.php. The issue is that the menu is also shown on custom htaccess error pages when you open a not-existing URL which also ends with prices.php. I don't want to show the menu on these error pages.

Do you have a better solution for showing / hiding a sub-menu on each separate page or do you have any suggestion how to avoid showing the menu on the htaccess error pages even though the URL matches?

Thanks,

Philip