Efficiently Pull Values From Other Pages

Hello. I’m pulling a few values from a page other than the current using $pages->find(). Is it more efficient to populate a var with the page object first like…

$other_page = $pages->find("about");

then use $other_page->title(), etc. or is it just as efficient pull each value like…


thanks in advance for your insight.

1 Like

Just guessing performance-wise, but I would think it is more efficient to save the page in a variable first and then get the title, text and other information.

From a clean code perspective, separating logic from presentation, this is advisable anyway. You would define your variable in the controller, and echo the stuff in the template.

Gotcha. It certainly feels like it would be more efficient. I don’t pretend to fully grasp exactly what’s going on there, but if feels as if its making one call to the kirby system and feeding the page from that one call instead of making multiple calls.

Controllers are something I’ll work into the process after I get comfortable with the basics.

Thanks for you input.