Hi!
In my navigation setup I need to add a page to an existing pages collection:
<?php
$navigationItems = $site->find("examplepage1", "examplepage2", "examplepage3");
if($site->find("specialpage")->hasListedChildren()){
$navigationItems = $navigationItems->append("specialpage");
}
?>
The special page needs to be appended before the two last navigation items. So I’m trying this:
if($site->find("specialpage")->hasListedChildren()){
$navigationItems = $navigationItems->offset(-2)->append("call");
}
But then looping over the navigation items to construct the navigation, the foreach loop gives me a Call to a member function title() on string
error later in the code.
Error occurs here:
<?php foreach($navigationItems as $navigationItem): ?>
<?= $navigationItem->title()->html() ?>
<?php endforeach ?>
Am I misunderstanding the append()
function and it’s generating a string instead of a page(s) object?
If I use add()
, appending works fine but add can’t use offset()
, can’t it?
Thx!