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   14048 Views

Avatar
Mo

Community Member, 541 Posts

24 February 2010 at 3:00am

Edited: 24/03/2010 10:52pm

Hi All,

Just thought I would announce that I am releasing a new module for your scrutinizing. Basically, it allows you to create custom navigation menus (such as "Header", "Footer" etc) and then link to these menu's from your template using <% control CustomMenu(menuslug) %>.

Its still pretty basic, but lets you build a menu from a TreeMultiselectField, give that menu a slug and return a DataObjectSet of pages to your template when called.

In the future I plan to add Versioning support, but any suggestions welcome :).

Download link: http://www.assembla.com/spaces/silverstripe-modules/documents/dQoxrEiiar37wFeJe5afGb
Browse Source: http://www.assembla.com/code/silverstripe-modules/subversion/nodes/custommenus
SVN Trunk: http://subversion.assembla.com/svn/ssmodules/custommenus/trunk

I look forward to any feedback.

Mo

Edit Just noticed the svn link above isn't correct, have changed it now. Also, added direct link to SVN trunk.

Edit Changed SVN link to proper link :).

Avatar
Hamish

Community Member, 712 Posts

24 February 2010 at 2:49pm

I couldn't tortoiseSVN it, but pulled the zip and having a peak. Looks good - one little thing, it might be a good idea to change:

<?php
class CustomMenu extends Extension {
	public function CustomMenu($menu = null) {
		if($menu) {
			if(DataObject::get_one('CustomMenuHolder',"Slug = '$menu'")) {
			...

to

<?php
class CustomMenu extends Extension {
	public function CustomMenu($menu = null) {
		$menu = Convert::raw2sql($menu);
		if($menu) {
			if(DataObject::get_one('CustomMenuHolder',"Slug = '$menu'")) {
			...

I'm sure someone will create a menu slug like "John's Links" at some point.

Avatar
Mo

Community Member, 541 Posts

24 February 2010 at 11:29pm

Hi Hamish,

Cheers for that, can't believe I didn't think of it, I must have been slacking off! :)

I have added it to the trunk, what is the issue you are having with tortoise?

Mo

Avatar
cake

Community Member, 19 Posts

27 February 2010 at 1:05am

I think the correct URL for the svn checkout is:

http://subversion.assembla.com/svn/ssmodules

or

http://subversion.assembla.com/svn/ssmodules/custommenu

I will test your module now because this is exactly what i need ;-) Thanks for this nice little module!

Avatar
MarcusDalgren

Community Member, 288 Posts

27 February 2010 at 3:39am

Hi Mo.

I'm trying to use your module right now but I'm getting a javascript error saying $("Form_EditForm") is null on line 207 of LeftAndMain.js when I try to click on a newly created menu. This error also appears when loading the Menus area in SideTabs.js on line 64. I'm trying to run the module on version 2.3.5, is this 2.4 only?

Avatar
cake

Community Member, 19 Posts

27 February 2010 at 4:31am

Edited: 27/02/2010 5:40am

Yes, i can confirm this bug. You can workaround it if you call admin page with params like: /admin/menus/show/1
But this doesn't solve the problem itself.

I am really new to ss but i think there might have changed something in EditForm(). EditForm() returns if there is no result and it won't call getEditForm() in CustomMenuAdmin.

But there's another issue. It pops up if you click the pages dropdown.

404//I can't handle sub-URLs of a CustomMenuAdmin object. prototype.js?m=1226464322 Line 658

Another one:

There is missing a ?> at the end of _config.php

Avatar
Mo

Community Member, 541 Posts

1 March 2010 at 12:06pm

Edited: 01/03/2010 12:08pm

Hi Smurkas,

Are you using the Zip file or an SVN Checkout from the trunk?

Cake, what version of SS are you running on?

Cheers for everyone's help on this so far, I am looking forward to making this module as usefall as it can be :).

Mo

Avatar
MarcusDalgren

Community Member, 288 Posts

1 March 2010 at 9:17pm

I did an SVN checkout. Should I use the zip file instead?

Go to Top