3214 Posts in 848 Topics by 810 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1338 Views |
-
Generated Menu Items

28 May 2009 at 2:01pm
I want to be able to have generated menu items displayed as children of a custom page type.
These menu items wouldn't be actual children, but would point to methods in my page_controller. Is there a 'standard' or best way to do this? The easiest way I think would be to have a custom 'MenuChildren' method in my page class and refer to that in the navigation template - is there a better way?
Cheers,
Rane
-
Re: Generated Menu Items

29 May 2009 at 12:58am Last edited: 29 May 2009 12:59am
Hello,
Do you mean that you want a given page type to have "fake" children? I've played a little with this: enough to prove the concept but not enough to go live with it.
public function Children() {
$children = new DataObjectSet();
foreach ($this->Children as $childTitle => $childLink) {
$page = new Page();
$page->Title = //$childTitle;
// unsure how to set child page's URL/link
$children->push($page);
}
return $children;
}Hope this helps,
Ben -
Re: Generated Menu Items

27 October 2009 at 5:39am Last edited: 27 October 2009 5:41am
For my purposes the easiest solution was to override Children, and start by invoking super::Children() and then modify the dataset, like this:
public function Children(){
$children = parent::Children();
if($children) {
foreach($children as $child) {
if ($child instanceof TemaArtikler){$child->Overskrift = DataObject::get_one("StatiskTekst")->ArtiklerOverskrift;
$child->MenuTitle = $child->Overskrift;
$child->Beskrivelse = DataObject::get_one("StatiskTekst")->ArtiklerTekst;
}}
}
return $children;
}
}The above code replaces the title of all "TemaArtikler" pagetypes with userspecified text from a static object.
Hope this helps.
edit: added code tags
| 1338 Views | ||
|
Page:
1
|
Go to Top |


