1. How many times does it go through the content?
Does it cache the query the first time, or does it go through the files every time?
$children1 = $page->children();
$children2 = $page->children();
$children3 = $page->children();
2. Same as the first question
$children1 = page()->children();
$children2 = page()->children();
$children3 = page()->children();
3. Why using $page instead of page()?
4. If I ask the same about $site / site(), do I get the same answers?
1 Like
Yes, it does .
jenstornell:
Same as the first question
The result of page()
is cached as well .
jenstornell:
Why using $page instead of page()?
Regarding performance: Less methods need to be called if you use $page
, as that variable is already defined. page()
is more for use in functions with different variable scopes.
In the end it shouldn’t matter which one you use, but $page
also worked in Kirby 1 and is used in examples and themes a lot.
jenstornell:
If I ask the same about $site / site(), do I get the same answers?
Yes.
Awesome! I use page()
when $page
is not defined, for example in plugin functions, called from the template.
Sidenote
My first bet who would answer this question was you @lukasbestle . How correct I was! My second bet would be @texnixe .
Me too.
That’s exactly why page()
exists in Kirby 2.
Haha.
Yes, we moderators basically live in this forum.
texnixe
September 15, 2015, 12:04pm
5
There is some truth in that
@lukasbestle @texnixe I love you both so much for living here