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.

All other Modules /

Discuss all other Modules here.

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

New Module: Custom Menus


Reply


56 Posts   8147 Views

Avatar
Andi

Community Member, 2 Posts

27 May 2010 at 9:25pm

Mo,
Maybe i want to ask your help. I've been installed your module to SS 2.3.4. It's work well. The question is, can i modify it to specific ID which is a child from main menu. Example, "A" had some child named "B", "C", "D" so i want to call only for "D" directly. Any solutions??.. T_T

I'm a newbie here. And need your help to cuztomizing to call it on SS page.

Avatar
Mo

Community Member, 510 Posts

27 May 2010 at 9:52pm

Hi Andi,

Do you mean that you want to use the module to create sub navigation? Or make it appear only on certain pages? Or maybe something completely different?

If its one of the first too, I would sugest adding a variable to your page class, something like:

'ShowMenu' => 'Boolean'

Add that to the cms as a CheckboxField and then in your template nest the menu code inside something like:

<% if ShowMenu %>
...
<% end_if %>

Mo

Avatar
Andi

Community Member, 2 Posts

27 May 2010 at 9:58pm

This is the case details. I have a photo in my HomePage.ss. I want to insert the link in the image, which will go directly to the child page that is in the main menu.

Avatar
muktibowo

Community Member, 2 Posts

27 May 2010 at 10:44pm

Edited: 27/05/2010 10:48pm

hmmm... ic ...

I assumed that you want to display the last child page from the Main Menu let you insert the following code:

<% control CustomMenu(SLUG) %>

<% if Last %>

....
<a href="$Link"><img border="0" src="your photo URL"></a>
....

<% end_if %>

<% end_control %>

Post back if it works!!... ^_^

Avatar
Mo

Community Member, 510 Posts

27 May 2010 at 11:13pm

Or if you want it to appear next to the Homepage link, and the image has been attached via the CMS, you could do something like:

...
<% if HomePagImage %>
<li><a href="$Link">$HomePageImage $Title</a></li>
<% end_if %>
...

Cheers,

Mo

Avatar
dvdsetshop

Community Member, 8 Posts

31 May 2010 at 6:47pm

Brilliant, crossing fingers must have worked!

-----------------------------------------------------------------------------------------------------
www.dvdsetshop.com

Avatar
plungerman

Community Member, 2 Posts

8 June 2010 at 3:56am

Edited: 08/06/2010 3:56am

can anyone suggest a way that i might be able to pass a variable to the custom menu handler? that is, instead of passing in a menu slug, you would pass in the URLSegment:

<% control CustomMenu(URLSegment) %>

that way, you can give the custom menu slug the same value as the page slug and display a menu automatically, if said menu exists. if not, display a default menu.

Avatar
Mo

Community Member, 510 Posts

9 June 2010 at 4:40am

Hmm, At the moment this would be a little tricky. The best way I can think of it would be to add a $has_one to your Page class, something like:

$has_one = array(
'CustomMenuLink' = 'CustomMenu'
);

Then you would add a Dropdown field (or something like that) to the CMS and have a custom method on your page controller, something like:

public function loadMenu() {
return DataObject::get_by_id('CustomMenu',$this->CustomMenuLink()->ID);
}

Then you could add this in your template:

<ul>
<% control loadMenu %>
<li>$Title</li>
<% end_control %>
</ul>

Just a couple of disclaimers:

1. This isn't tested, you will probably have to tweek it to get it working.

2. This should work in 2.4 with a little modification, but I am not sure about 2.3 (or lower).

Hope that helps,

Mo