1259 Posts in 348 Topics by 484 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 579 Views |
-
Show selection of links from various sections

8 October 2010 at 12:51pm
My apologies if this has already been asked, I wasn't really sure how to define it well in search terms.
My site has two levels of navigation, and on the home page I want to have a set of "Quick Links" which are a selection of 2nd level links from various sections. At the moment I've just got them coded in manually but of course this isn't ideal in case the client renames or deletes one of those pages.
Is there any way to get a selection of different links into a list like that?
-
Re: Show selection of links from various sections

21 October 2010 at 10:53am Last edited: 21 October 2010 10:53am
The way I would do this is by adding a boolean to the page class to define if you want any page to show in the Quick Links.
So in the Page class:
public static $db = array(
"ShowInQuickLinks" => "Boolean"
);public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Behaviour', new CheckboxField('ShowInQuickLinks', 'Show in quick links?'), 'ShowInSearch');
return $fields;
}Then in the Page controller you could have a method to find all the children that should show in the Quick Links:
function QuickLinksChildren() {
$doSet = DataObject::get('Page', 'ShowInQuickLinks= 1');
return $doSet ? $doSet : false;
}Then in your template you can just call a control on this method:
<% if QuickLinksChildren %>
<ul id="QuickLinks">
<% control QuickLinksChildren %>
<li><a href="$Link" title="Go to the $Title.XML page">$MenuTitle.XML</a></li>
<% end_control %>
</ul>
<% end_if %>
| 579 Views | ||
|
Page:
1
|
Go to Top |


