For a certain design, I cannot use foreach loop page-call.
Therefore, I’m using something like this :
<a href="<?php echo page('home')->url() ?>" >
<?php echo html(page('home')->title()) ?>
But I need to include this in my a tag :
<?php e($subpage->isOpen(), ' class="active"') ?>
How could I do it without having a loop like this :
<?php foreach($pages->visible() as $subpage): ?>
You can simply use
page('home')->isOpen() instead of
I would suggest a check if the page with that uid exists, though. There might always be a page with the uid
home, but for other pages you should do that:
<?php if($mypage = page('home')): ?>
<a href="<?= $mypage->url() ?>" <?php e($mypage->isOpen(), 'class="active"') ?>>
<?= $mypage->title() ?>
<?php endif ?>
If you ever want to change the uid of the homepage you can use
$site->homePage() by the way.
Of course… it seems so obvious now I’m so stupid haha
Thanks a lot !