Custom menu per page

Home Forums Pro Support Custom menu per page

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #68724
    Anonymous

    I’m wondering if it is possible to change the menu options based on the page that is being accessed?

    Thanks so much,
    Matthew

    #68737
    Peter FeatherstonePeter Featherstone
    Participant

    Hey Matthew,

    Sure, using the shortcode you can do this, a guide is below:

    https://responsive.menu/knowledgebase/using-the-shortcode/

    Not all options can be changed based on the page, but there are a few that can.

    If you want a full list of options you can look in the default_options.php file for a list but again not all will work as options.

    Hope that helps

    Peter

    #68736
    Anonymous

    I’m a bit confused about the syntax…

    The article you linked to indicates that the shortcodes should work when placed on the page itself (unless I misread). Doing so only places the shortcode on the page as text.

    May I ask the exact syntax if I desired to place this in header.php?

    As an example:
    <?php echo do_shortcode(‘[responsive_menu_pro menu_to_use=”menu1″ menu_title=”example”]’); ?>;

    How does header.php know which specific page this code would apply to? OR is there a header.php associated with each page that I’m simply unaware of?

    Thanks so much for the help :),
    Matthew

    #68735
    Anonymous

    I was in error and figured this out by placing the proper short code on the pages I want.

    New problem though!!

    I have a conflict:

    I used this code to have the menu only show when users are logged in:

    if(is_user_logged_in())
         echo do_shortcode('[responsive_menu_pro]');

    However, the custom menu for the specific pages I want will no longer show, or even open for that matter. How do I fix this conflict?

    #68734
    Peter FeatherstonePeter Featherstone
    Participant

    Hey Matthew,

    What do you mean by a conflict?

    You will need to combine your if statements, otherwise it sounds like you are trying to put more than one shortcode on a page.

    Can you advise if that is the case?

    Peter

    #68733
    Anonymous

    Here is the problem, if you enable short codes, the plugin removes all menus until a short code is used. A nice feature would be to have a drop down list that we could select a default menu for pages that do not have short codes. That way I don’t have to place a short code on every single page, you know what I mean? OR is there a way to do that, and I just know?

    Keeping the above in mind, can you suggest a php code? If no shortcode on page, then use menu ‘example’… is such a thing possible?

    #68732
    Peter FeatherstonePeter Featherstone
    Participant

    Hey Matthew,

    You shouldn’t have to place the shortcode on every single page.

    You normally just add it to your header.php file. I haven’t heard of someone putting it on every page, because as you say that would be very annoying and time consuming.

    Is there a reason you are doing it on every page?

    Peter

    #68731
    Anonymous

    I need a different menu for about 50 pages. Maybe I’m misunderstanding something or doing something wrong?

    #68730
    Anonymous

    I needed lots of different menus for different pages, and only to be displayed when logged in.

    For others that might be interested, here is what worked for me, don’t know if it’s “proper” as I’m new at this, but it did work:

    	        <?php
    
    		$pagerange1 = range(310, 360); //page id range variable
    		$pagerange2 = range(1000, 1400); // page id range variable
    		
    		if (is_user_logged_in() && is_page( $pagerange1 )){ //if user is logged in and on pagerange1, run menu1
    			echo do_shortcode('[responsive_menu_pro menu_to_use="menu1"]'); }
    		elseif (is_user_logged_in() && is_page( $pagerange1 )){ //if user is logged in and on pagerange2, run menu2
    			echo do_shortcode('[responsive_menu_pro menu_to_use="menu2"]'); }
    		elseif (is_user_logged_in()) { //if user is logged in, run main menu
    				echo do_shortcode('[responsive_menu_pro menu_to_use="main"]');
    			}
    		?>
    #68729
    Peter FeatherstonePeter Featherstone
    Participant

    Hey Matthew,

    Requiring 50 different menus unfortunately is going to end up with quite a bit of messy code due to the nature of what you are trying to do.

    I think the most I’ve heard of before this was only 3 which is why I hadn’t quite realised how many you actually need.

    However, now looking at your code above it seems you only have 3 different menus or is there extended code somewhere.

    Your solution looks quite elegant, so well done!

    Peter

    #68728
    Anonymous

    I’m using your menu in a unique way I suspect. I’m not using it as a “menu” but more as a course navigation tool. I have pages set up for a course, each course has 10 topics (for example). If a person is on topic 5, I want them to open the navigation menu, and be able to select other topics. I’ve added a back link in each menu to take them to the homepage. I’m currently at 3 page ranges deep, but as you can imagine… depending on the amount of courses I have, this might get crazy. Haha.

    Alternatively, I was thinking we could use the is_tag function, and apply a unique tag to every post in a course. I’m still learning and trying different things. 🙂

    #68727
    Peter FeatherstonePeter Featherstone
    Participant

    Hey Matthew,

    It does sound quite unique.

    Can’t you just have a normal menu that has the topics and courses in a normal menu structure and have the menu open on just the current parent page?

    I may have misunderstood what you are doing though.

    Peter

    #68726
    Anonymous

    You could do it that way, but I don’t find it as aesthetically pleasing depending on the size of the menu. It means you would see everything else, other than just the course navigation. I was kinda going for a cleaning look, whereby one “entered” into a course. The menu than displays only information relevant to that specific course. Does that make sense? 🙂

    #68725
    Peter FeatherstonePeter Featherstone
    Participant

    Hey Matthew,

    Yep that makes complete sense 🙂

    Peter

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Custom menu per page’ is closed to new replies.