FORUMS CLOSED DUE TO SPAM. YOU STILL CAN ADD POST!

How to display Layout names in the Page tree?

Feed 2 posts, 2 voices

Avatar
35 posts

I’d like to see in the page tree the name of the layout a page uses.
In frog/app/view/page/children.php I added this (and tried variations on it):

<?php if (! empty($child->layout_id)): ?>
  <small class="info">
    <?php echo $child->layout->name; ?>
  </small>
<?php endif; ?>  

As you can guess I cannot get it to work.
The if statement works though, and I can get the $child->layout_id to show up.

Any ideas?

 
Avatar
11 posts

Seems like the layout data model is not loaded for child pages.
So you’ll first have to load the layout data:

$layout = Layout::findById($child->layout_id);

and then you can do:

echo $layout->name;
 
Avatar
35 posts

Great, I will check it out right away, thanks for your swift reply!

18:06
Works like a charm. Thanks. I need to format it nicely for the root page still, but that’s not too difficult.