Call specific page

Hi guys,

I have an extremely newbie question. The answer is probably even in the documentation, but I can’t find it. :smiley:

So, here’s what I need:
I have a page called ‘home’ which contains a page called ‘countdown’.
Now, I want to get the uid (actually the content, but that’s not the problem) of this ‘countdown’ page and display it on the home page. But how?

I tried various things (inside the countdown.php snippet) like

<?php echo $page->uid() ?>
<?php echo page('countdown')->uid() ?>
<?php echo $page()->page('countdown')->uid() ?>

but none of them do the trick.

Can you help me out? I imagine the solution is very simple.


Already found the solution…

<?php echo $page->find('countdown')->uid()

I’m not sure why you’re tring to access the uid of a page when you already know it’s ID. What are you trying to do with that uid ?

UID was just a test to see if anything gets returned at all. I am actually trying to get the content of the page (date()).

1 Like

A small tip for you:
If the uid of the page changes, your code would break the whole page. The function would not find the “countdown” page, display an error and stop rendering the rest of the page.

Especially if you’ve got clients that edit the website this could save you some trouble. You can even define a fallback or display a warning message in an “else” part:

if($countdown = $page->find('countdown')) {
  echo $countdown->uid()



For the record your first tests didn’t work because the path of your page is home/countdown, not just countdown. So you needed $countdown = page('home/countdown').

Your solution works on the home page because $page is the 'home' page in that context, and $page->find looks into its descendants. So what you were doing is similar to page('home')->find('countdown').


Cool, I didn’t know page(‘home/countdown’) or paths in general work. That’s basically the solution I was looking for. Thank you. :slight_smile:

@thguenther Thanks for the hint, valid point. It basically should never change but I see how your solution is a lot more future-proof.

Will implement both of those. :slight_smile: Thanks guys.