Custom Page Attributes in Next/Prev block

Hello all,

I have added a custom attribute with the handle sample_loc to all sibling pages under a directory called “Work”, and I want to use the Next & Previous Nav block to display that attribute with the page title. I figured I needed to add it to the controller.php file, so I created a custom controller.php file within my custom next_previous template folder, where I have a custom view.php file as well. I can’t figure out how to pass this data through, as I don’t have a strong understanding of how controller.php files work their magic.

Can anyone please point me in the right direction?

Thank you,

in the block controller view() method use:
$my_attribute = … // whatever you are working out
$this->set(‘my_attribute’, $my_attribute)
Then in the block view, you will have $my_data available as a variable.

However, rather than override the controller, you should be able to do everything by overriding the view or creating a custom view template. Much simpler to do and less risk of unintended consequences.

In the view you should be able to get your attribute directly rather than passing it from the controller.

Thank you for the quick reply, JtF.

Your suggestion sent me right down the path I overlooked.

I ended up accessing the custom attribute directly in my custom view.php file using $nextCollection->getAttribute('my_custom_attribute_handle')

Thank you again!