17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1375 Views |
-
custom <% control Menu(1) %> or <% control Level(1) %>

13 February 2008 at 12:42pm
What order does either Menu(integer) or Level(integer) return in?
Is it possible to over-ride either Menu(integer) or Level(integer) in your own controller such that you can specify the order you wish?
Or even <% control children %>?
I was looking at built-in-page-controls, which contains a link to custom-page-controls which does not yet exist.
-
Re: custom <% control Menu(1) %> or <% control Level(1) %>

13 February 2008 at 2:31pm
It returns it in the order you have arranged pages in the CMS (You'll notice you can drag and drop pages around in the CMS, or right-click a 'parent' page and Sort them alphabetically).
What order are you thinking of re-ordering items by? Date? Alpha? Note that it's best to have the CMS order and public page order the same, otherwise site administrators will become confused.
-
Re: custom <% control Menu(1) %> or <% control Level(1) %>

13 February 2008 at 3:12pm Last edited: 13 February 2008 3:13pm
I think the order is literally determined by the order of the pages in the site-tree in the left pane of the cms...
(Edit: Sigurd beat me to it ;) )
-
Re: custom <% control Menu(1) %> or <% control Level(1) %>

13 February 2008 at 4:15pm
Possible example:
Let's say there is a WidgetHolder, with Widgetpages; WidgetHolder can only have WidgetPages as children and each WidgetPage has a price associated with it.
Let's say that you wanted each WidgetPage to display in price order on the WidgetHolder template, however, because you knew you had so many WidgetPages, you also wanted to create an inline navigation list up to the top, so people didn't have to scroll all the way to the Widget of their choice.
Wouldn't it be easier to write a custom control to return children in price order?
-
Re: custom <% control Menu(1) %> or <% control Level(1) %>

13 February 2008 at 9:36pm
Instead of Menu() or Level you could have a function like
function GetWidgetsInPriceOrder() {
$Widgets = DataObject::get("WidgetPage", "", "Price DESC","", 10);
return($Widgets) ? $Widgets : false;
}1st argument = what you want to get eg widget page
2nd argument = the filter (you probably don't need this - Ive set it as "")
3rd argument = the order which you want it sorted by (Price in DESC or ASC order for example)
4th = Join (dont worry about that)
5th = Limit AKA how many you WidgetPages you want to limit to (10)Then in the template do <% control GetWidgetsInPriceOrder %> instead of Menu.
| 1375 Views | ||
|
Page:
1
|
Go to Top |



