Using Page Attributes in Concrete5 Themes
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(); ?>
7 Comments
melat0nin on January 13th, 2010
Is it possible to show the last date a page was edited, rather than the date it went public?
Chris Seymour on January 13th, 2010
melat0nin,
Not sure if this is it, but try replacing getCollectionDatePublic with getVersionDateCreated
melat0nin on January 14th, 2010
Thanks Chris, but unfortunately that doesn’t work - getVersionDateCreated is an undefined method.
Chris Seymour on January 14th, 2010
melat0nin,
I’d try searching the concrete5 forums or API and see what you can come up with.
Dave Kinsella on February 24th, 2010
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.
Chris Seymour on February 24th, 2010
Dave, welcome to the community! I’d say I’d have to agree with you! Concrete5 is most certainly a breath of fresh air





ep2000 on September 29th, 2009
Very helpful! I haven’t seen this anywhere else and its something i’ve been looking for, Thanks!