Quantcast
Channel: c5mix Blog » Tips
Viewing all articles
Browse latest Browse all 6

Using Page Attributes in Concrete5 Themes

$
0
0

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();
?>

Viewing all articles
Browse latest Browse all 6

Trending Articles