Skip to content

How to output subpage content in a layout file? #848

Discussion options

You must be logged in to vote

The class YellowContent gives access to content files. This example outputs one specific page:

<h1><?php echo $this->yellow->content->find("/shop/producta/")->getHtml("title") ?></h1>
<?php echo $this->yellow->content->find("/shop/producta/")->getContent() ?>

Subpages are also called children. This example snippet outputs multiple pages in a loop:

<?php $pages = $this->yellow->content->find("/shop/")->getChildren() ?>
<?php foreach ($pages as $page): ?>
<h1><?php echo $page->getHtml("title") ?></h1>
<?php echo $page->getContent() ?>
<?php endforeach ?>

You could also use the current page as starting position. Another example, the loop stays the same:

<?php $pages = $this->yellow->page->…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pftnhr
Comment options

Answer selected by pftnhr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants