Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

New Module: Custom Menus


Go to End


56 Posts   14049 Views

Avatar
Mo

Community Member, 541 Posts

13 July 2011 at 3:23am

No probs juneallison,

It is an interesting conundrum RE: centralising that info into one place. You could create a "Link" DataObject (or something similar) and use a has_one to associate it with a page. But you would probably have to use ModelAdmin to administer your new object, which probably end up taking just as much time to edit as it would being attached to a page.

Logically, I think it makes more sense for this data to be part of your page object, rather than having to create new interfaces to try an manage it.

What do you think?

Mo

Avatar
Olvis

Community Member, 1 Post

16 July 2011 at 12:09am

Hi there,

I think "Custom Menus" is a great module. However, I also had problems with a multilingual site, when a client asked for the inclusion of multilingual support on a running site using "Custom Menus" with three different menus. Actually, I couldn't even get the menu items to show up in the frontend except those for the default locale, although the pages had content in all languages.

I found a solution which might be considered ugly, but I had not much time or budget and it helped me out.

I added this line to the Field() method in CustomMenuField.php on line 13:

Translatable::disable_locale_filter();

Now I could access all pages in all languages under the "Pages" tab and build different menus for the separate languages using a unique menu slug with the correct locale, e.g. "footer-menu-en_GB" or "footer-menu-de_DE".

With a simple conditional logic I was now able to render the correct menu for the given language:

<ul>
     <% if ContentLocale = de-DE %> 
          <% control CustomMenu(footer-menu-de_DE) %> 		  
               <li><a href="$Link" class="$LinkingMode">$MenuTitle.XML</a></li>	   		  
          <% end_control %>
     <% end_if %>
     <% if ContentLocale = en-GB %> 
          <% control CustomMenu(footer-menu-en_GB) %> 		  
               <li><a href="$Link" class="$LinkingMode">$MenuTitle.XML</a></li>   		  
          <% end_control %>
     <% end_if %>
</ul>

Again, this is probably not the best solution, but it works perfectly and I could keep the old structure of my site. The only drawback is that you end up with a lot of pages under the pages tab. Maybe it would be nice to have a select-field for the languages as a filter.

Hope that was helpful for someone else. In my case it saved my day.

Avatar
juneallison

Community Member, 110 Posts

16 July 2011 at 12:23am

Mo -

"Logically, I think it makes more sense for this data to be part of your page object, rather than having to create new interfaces to try and manage it. What do you think?"

I agree. That is what I was getting at in my last message but you did a much better job of articulating the idea.

Thanks!

Avatar
Mo

Community Member, 541 Posts

17 July 2011 at 1:57am

Hi Olvis,

Unfortunately, I very rarely need to produce multilingual sites, so I have been a bit unsure how to add this functionality.

Is your suggestion that you would have normal generic menu's (say, for example: "Main Menu", "Footer Menu" etc) and that for each menu you would have the ability to assign pages from all languages to that menu independently?

So, for example, you could have an English language version of a site with "about" and "services" assigned to a menu, but on (for example) a German version of that site, only the "about" page would be assigned?

I think that could work quite nicely, and would also allow you to build independant regional sites (using the same core navigation and templates) quite easily in the CMS.

Not sure how you would represent this in the UI though. You could use a dropdown to filter. But you could also have something like a tab for each language in your site.

I think I will need to give it some thought and have a play around.

Mo

Avatar
redactuk

Community Member, 117 Posts

7 August 2011 at 11:29am

Edited: 07/08/2011 11:49am

Having same problem as others i.e. when I edit a menu it's just default Page tabs displayed.

I'm using a SS 2.4.5 and latest downloads fromt GitHub for DataObjects, Uploadify and CustomMenus.

I actually think this may be related to SS or DataObjects, in that yesterday (on a separate new install) I started to work on creating a new Admin module (using the SS documentation examples), and whatever I did I could not get the tabs/fields for my module to display. So I remembered that I was going to install and test CustomMenus for another project and that too extended LeftandMain. So I was surprised to find the exact same problems as CustomMenus.

So I'm thinking this is maybe bug in SS?

Thanks

Avatar
redactuk

Community Member, 117 Posts

7 August 2011 at 12:26pm

Edited: 07/08/2011 12:27pm

Ok I must have missed the download you posted earlier for 0.2.5a - updating to that worked!

Note: For my own Admin panel I was using http://doc.silverstripe.org/sapphire/en/reference/leftandmain as a guide and there is no mention of the need for the javascript you added to ensure EditForm displays. i.e. need to have extra javacript to get a customised right panel to display?

PS As a result of this issue now had time to test CustomMenus - awsome work... can't think how useful this will be for lower level menus, especially being able to items from other levels or parts of the tree . Many thanks for you work on this :)

Avatar
juneallison

Community Member, 110 Posts

8 August 2011 at 10:14am

@Mo - i don't know if this has been documented anywhere but when one of my site's admins went to delete a page the entire site (front-end) produced an error. Sorry I didn't write it down! But I want to say this was a result of deleting a page prior to removing it from the custom menu. Other pages - not found in the custom menu - have deleted without a problem. It seems like it would be nice if the user could receive a message something like "you must remove this from the custom menu" before deleting.

I can test this out on a sandbox site later if you like.

Thanks!

Avatar
juneallison

Community Member, 110 Posts

16 September 2011 at 3:21am

@Mo - to comment on my previous problem: The error happened when a page was unchecked but the id had not been removed from the order list.

I'm now having the opposite problem. I just checked a page I want to add and updated the menu. I went to the order page and it is not appearing there. So I don't know what the page ID number is that I need to add to the list.

Any help would be great.

Thanks!

Go to Top