[SOLVED] Multiple menus with use_hierarchy set to true

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
wiseguy
Forum Members
Forum Members
Posts: 16
Joined: Wed Oct 07, 2009 10:01 pm

[SOLVED] Multiple menus with use_hierarchy set to true

Post by wiseguy »

I have a question now when use_hierarchy is removed from config.php and instead always is set to "true" in version 1.8.

From reading this forum I've learned to create additional menus by creating a new page (with alias "menu2" in my example), disable "Show in Menu" for it and then create the menu items/pages as sub-pages. The additional menu is then showed by using a tag similar to {menu template="menu2template" start_page="menu2" start_level="2"}. After upgrading to version 1.8 and thus getting use_hierarchy=true, the urls to these menu items got an unwanted prefix, i.e. /menu2/. The same goes for urls in sitemap.xml created by the SiteMapMadeSimple module.

One could use the same method to create special listings, e.g. a travel directory that has a list of countries and possibly cities in a sub-level. All these listings are affected by the use_hierarchy=true as prefixes are added to the urls.

What is the solution to this new issue that was introduced in version 1.8?
Last edited by wiseguy on Sun Aug 15, 2010 12:20 am, edited 1 time in total.
JeremyBASS

Re: Multiple menus with use_hierarchy set to true

Post by JeremyBASS »

to be honest I don't know why you’re doing it that way.. but.. here is a nifty thing to note and may help save your established sites..

http://localhost/sandy_1-8-beta/how-cms ... heets.html
http://localhost/sandy_1-8-beta/templat ... heets.html

that is the same thing... try it out..

so you could just add |replace:'how-cmsms-works/':'' and that would knock it out.. Just a thought.. but I would think you need to rethink how your are approaching  your menus... I use submenus all the time and don't have this issue FWIW... hope this helps .. Cheers -Jeremy
wiseguy
Forum Members
Forum Members
Posts: 16
Joined: Wed Oct 07, 2009 10:01 pm

Re: Multiple menus with use_hierarchy set to true

Post by wiseguy »

JeremyBASS wrote: to be honest I don't know why you’re doing it that way..
Interesting, I had no clue that would work. So to "convert" pre-1.8 sites to 1.8 I could modify the menu templates somehow to strip out the /menu2/ part from the urls? And what about sitemap.xml generated by SiteMapMadeSimple?

Also, if you could please enlighten me with how you create your own sub-menus.

Thanks!
JeremyBASS

Re: Multiple menus with use_hierarchy set to true

Post by JeremyBASS »

I'm short on time.. so let’s do it the fast way.. Can you just send screen shots of the page list expanded out.. and some samples of what your menus are now as output.. Then you can see may-be an alt way to create the same thing that works more inline with the system?  That work.. I don't have much time to spear so may-be someone else can jump in too, but menus can be pretty powerfully and flexible.  Cheers -Jeremy
JeremyBASS

Re: Multiple menus with use_hierarchy set to true

Post by JeremyBASS »

ha.. is it that easy :D
wiseguy
Forum Members
Forum Members
Posts: 16
Joined: Wed Oct 07, 2009 10:01 pm

Re: Multiple menus with use_hierarchy set to true

Post by wiseguy »

Dr.CSS wrote: Have you tried putting this back in your config file?...

$config['use_hierarchy'] = false;
I've tried it now without success, cleared cache as well.


JeremyBASS: Thanks for being helpful.

So far I've mainly used the described multiple menus method for creating footer menus which point to pages that should not be shown in the main menu, and the menus also differs in styling, e.g. horizontal with dash as separator instead of the vertical main menu.

For a project which I hope to start this week, I was about to use the same method for creating listings of countries and cities where some code and of course content will the unique for each page. I was also going to ask the forum how to sort the listings in alphabetic order, probably adding some sorting function into the menu template. And the urls should be like site.com/madrid/ or possibly site.com/spain/madrid/ but not e.g. site.com/destinations/spain/madrid/.

The more flexibility and choices you have to format the urls, the better. There's a reason behind why seo plugins are so popular for other cmses as well.
wdstuff54
New Member
New Member
Posts: 4
Joined: Mon May 10, 2010 11:24 pm

Re: Multiple menus with use_hierarchy set to true

Post by wdstuff54 »

Hey,

I'm having the same problem, I used the same method for multiple menus and now it is showing all the children in the URL.

JeremyBASS, if you have time could you briefly explain how you avoid this issue? Or perhaps recommend a good site to read up on it?

Thanks!
wiseguy
Forum Members
Forum Members
Posts: 16
Joined: Wed Oct 07, 2009 10:01 pm

Re: Multiple menus with use_hierarchy set to true

Post by wiseguy »

I posted a code change that works for my sites, and asked for comments on it, but the whole post was quickly removed by some anonymous moderator.

Please, can anyone here at least tell me what's wrong with discussing possible solutions?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Multiple menus with use_hierarchy set to true

Post by calguy1000 »

See what's in the forum rules.
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.
wiseguy
Forum Members
Forum Members
Posts: 16
Joined: Wed Oct 07, 2009 10:01 pm

Re: Multiple menus with use_hierarchy set to true

Post by wiseguy »

calguy1000 wrote: See what's in the forum rules.
All right, got it. We're not allowed to discuss code examples in the forum, at least not if it has to do with the core.

It would be highly appreciated if anyone can suggest a pragmatic approach for finding an alternative non-hierarchical url solution (which does not require changes to the core).
wdstuff54
New Member
New Member
Posts: 4
Joined: Mon May 10, 2010 11:24 pm

Re: Multiple menus with use_hierarchy set to true

Post by wdstuff54 »

Hey, did you solve the problem? I'm still stuck on this.
nicmare
Power Poster
Power Poster
Posts: 1150
Joined: Sat Aug 25, 2007 9:55 am

Re: Multiple menus with use_hierarchy set to true

Post by nicmare »

i had the idea of a walkaround for this issue. in your menutemplate, replace

Code: Select all

href="{$node->url}"
with

Code: Select all

href="{$node->alias}.html"
modify file prefix.
i would recommend the use of canonical urls:

Code: Select all

{if isset($canonical)}<link rel="canonical" href="{$canonical}" />{elseif isset($content_obj)}<link rel="canonical" href="{root_url}/{$content_obj->mAlias}.html" />{/if}
because both, the hierarchy urls and the new urls still coexists. and therefore you have to tell google the right url! this is canonical url!

hope this helps!
User avatar
Augustas
Forum Members
Forum Members
Posts: 241
Joined: Wed Oct 17, 2007 6:09 pm

Re: Multiple menus with use_hierarchy set to true

Post by Augustas »

This workaround mind be Ok for the Menus.
However, the {cms_selflink} tag used in the content of the pages will produce not-wanted URLs
http://FollowTheRoad.com/ - living on the road...
http://www.kligys.com/ - asmeninis blog'as...
baresi
Forum Members
Forum Members
Posts: 129
Joined: Fri Jul 27, 2007 4:15 pm

Re: Multiple menus with use_hierarchy set to true

Post by baresi »

I have read the few other threads about this.

Besides the issue of hacking core files is this the best way? what about other instances of href="{$node->url}" and in other places/templates?

or is there 'more official' way of having www.mydomain.com/alias.php
LeisureLarry

Re: Multiple menus with use_hierarchy set to true

Post by LeisureLarry »

An unofficial, but easier way is the usage of a smarty output filter, which deletes the unwanted hierarchy from the html code. I don´t know how long this will work with new cmsms versions and I don´t know which modules should be defined as exceptions, but you can download a beta version of the plugin from my german (commercial) website. A short english readme.txt is in the zip-file.

At the moment I only couldn´t find a solution for my xml-sitemap (gsitemap.php) as it doesn´t use smarty.
Last edited by LeisureLarry on Sat Aug 07, 2010 12:39 pm, edited 1 time in total.
Post Reply

Return to “CMSMS Core”