Passing publication date from parent to child pages

I want to add a publication date to a top-level page and display it on all sub-pages. What is the best way to do this?

I have my template structure in Kirby set up like this:

Pages:

  • Issue (this is where the publication date should be set)
    – Feature Story
    – Articles
    – Events

I only want the date to show for “Issues” and their sub-pages but not on any pages outside of it. I have a date placeholder in my header.php template but I’m not sure if this is the best way to accomplish this.

This is the code snippet I currently have in header.php:

<?php echo $page->pub_date('F j, Y') ?>

Well, one way would be to just put that code not into the header but into the templates of the corresponding pages.

If you want it in the header, you can use an if statement, supposing that the template of the issues pages is called “issues”, something like:

<?php
if($page->intendedTemplate() == 'issue') {
 echo $page->pub_date('F j, Y');
}
if($page->parent()->intendedTemplate() == 'issue') {
 echo $page->parent()->pub_date('F j, Y');
}
?>