How to "apply" controller on a navigation system

OK, the title is weird, sorry for that.

On a snippet I create a navigation stuff using

<?php if ($page->hasPrev()) : ?>
    <span><?= $page->prev()->titre() ?></span>

There is a controller associated to the page, let’s name it painting. In this controller I computed a parameter named titre.
Problem is I don’t have access to these titre data. The line involved is $page->prev()->titre() and it seem the $page->prev() have not the painting controller applied on it.
I am pretty sure I am missing something really simple.

By the way, there is an error on the following cookbook’ page as the link to the dedicated controller’s documentation leads to an error.

In order to access the content of the painting controller I think you have to fetch it manually because it’s not automatically loaded.

I did not test it but you should be able to do something like this

$kirby->controller('painting' , ['page' => $page->prev()]);

This will return an array with all the data that’s returned by the painting controller

1 Like

What do you mean by parameter? But you are using whatever you have defined as if it was a page method?

1 Like

Thank you! Your answer put me on the right path!


1 Like


Problem solved. Thank you !!!