There will times in developing a concrete5 theme when you will want or need to display a Page Attribute with the theme files. One use of this would be to display the page name within an H1 tag at the top of each page as your page’s title. There’s a way to do this automatically within the theme so it doesn’t have to be added to each page manually. Here how you display Page Attributes:
Display Page Title
<?php echo $c->getCollectionName() ?>
Display Page Description
<?php echo $c->getCollectionDescription() ?>
Display Page Date
<?php echo $c->getCollectionDatePublic() ?>
This displays the date in default format like this: 2009-06-15 14:09:00.
To display the date in a format like this – June 06, 2009 – use this code:
<?php echo $c->getCollectionDatePublic("F j, Y") ?>
See more about the PHP date function for other date/time formatting.
Display Any Page Attribute
<?php echo $c->getCollectionAttributeValue('attribute_name') ?>
Display a Page’s Parent Page Name
<?php $page = Page::getByID($c->getCollectionParentID()); print $page->getCollectionName(); ?>


Very helpful! I haven’t seen this anywhere else and its something i’ve been looking for, Thanks!
Is it possible to show the last date a page was edited, rather than the date it went public?
melat0nin,
Not sure if this is it, but try replacing getCollectionDatePublic with getVersionDateCreated
Thanks Chris, but unfortunately that doesn’t work – getVersionDateCreated is an undefined method.
melat0nin,
I’d try searching the concrete5 forums or API and see what you can come up with.
Just what I was looking for, thanks for this. I’m having to get up to speed with C5 fast but really enjoying it – it’s the CMS I’ve been wanting for a long time.
Dave, welcome to the community! I’d say I’d have to agree with you! Concrete5 is most certainly a breath of fresh air
melat0nin,
getCollectionDateLastModified() in /concrete/models/collection.php
Cool thanks Chris.
Hi Chris,
Is there a tutorial somewhere (like above) on how to echo out file attributes and user attributes as well?
I’m struggling trying to find something in the C5 api where I can print out an attribute I’ve created for an image I’ve uploaded in File Manager…
Thanks,
osu
osu,
try this:
http://snipplr.com/view/23850/display-image-from-imagefile-page-attribute–concrete5/
you can see some other snippets I’ve created here:
http://snipplr.com/users/sinecera/
Pingback: Display a Page’s Grandparent Page Name | c5mix
When I try getCollectionAttributeValue, I got Fatal error: Call to undefined method Area::getCollectionAttributeValue() in …
I can’t find any solution.
krix, What is the exact code you’re using and where are you using it at?
very helpful.. thanks