Page 1 of 2

[SOLVED] Multiple menus with use_hierarchy set to true

Posted: Wed Jul 07, 2010 7:27 pm
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?

Re: Multiple menus with use_hierarchy set to true

Posted: Wed Jul 07, 2010 7:48 pm
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

Re: Multiple menus with use_hierarchy set to true

Posted: Wed Jul 07, 2010 8:04 pm
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!

Re: Multiple menus with use_hierarchy set to true

Posted: Wed Jul 07, 2010 11:54 pm
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

Re: Multiple menus with use_hierarchy set to true

Posted: Thu Jul 08, 2010 1:28 am
by JeremyBASS
ha.. is it that easy :D

Re: Multiple menus with use_hierarchy set to true

Posted: Thu Jul 08, 2010 2:28 am
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.

Re: Multiple menus with use_hierarchy set to true

Posted: Tue Jul 13, 2010 4:17 am
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!

Re: Multiple menus with use_hierarchy set to true

Posted: Tue Jul 13, 2010 2:36 pm
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?

Re: Multiple menus with use_hierarchy set to true

Posted: Tue Jul 13, 2010 2:41 pm
by calguy1000
See what's in the forum rules.

Re: Multiple menus with use_hierarchy set to true

Posted: Tue Jul 13, 2010 4:03 pm
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).

Re: Multiple menus with use_hierarchy set to true

Posted: Fri Jul 16, 2010 7:41 pm
by wdstuff54
Hey, did you solve the problem? I'm still stuck on this.

Re: Multiple menus with use_hierarchy set to true

Posted: Fri Jul 16, 2010 11:31 pm
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!

Re: Multiple menus with use_hierarchy set to true

Posted: Mon Jul 26, 2010 3:20 am
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

Re: Multiple menus with use_hierarchy set to true

Posted: Mon Jul 26, 2010 1:39 pm
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

Re: Multiple menus with use_hierarchy set to true

Posted: Sat Aug 07, 2010 9:31 am
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.