Concrete5 Tips

Concrete5 Code Snippets Dreamweaver Extension

Katz515 (a member of the Usagi Project - Japan’s concrete5 group) just posted a concrete5 code snippet Dreamweaver Extension in the concrete5 forums.  I already downloaded it and it’s a great little resource for those that use Dreamweaver to build concrete5 themes.

You can download the extension here:
Concrete5 Code Snippets Dreamweaver Extension

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

If Site is in Edit Mode, Display or Do This

If you need to display or do something in your concrete5 theme when the site is in edit mode, use this code:

<?php global $c; if ($c->isEditMode()) { ?> Do something here <?php } ?>

If User is Logged in, Display or Do This

Sometimes, when building a theme for concrete5 you might need to display some text or code that appears when a user is logged in to their site.  Here is how you do that:

<?php global $u;
if ($u -> isLoggedIn ()) { ?>
//Do Something
<?php } ?>