Meta data in blog entry

Permalink 1 user found helpful
I've just started trying Concrete5, using version 5.7, and I'm really amazed. As an average end user, I've never seen such an elegant CMS. It is a delight to use, really.

Now, one thing I miss is a kind of topic link in the meta header of the blog entry. Just under the page title there is the creation date and the user name. I would like to see there a link to the blog entry topic under which the blog post was posted.

I tried editing the file ../concrete/blocks/page_title/templates/byline.php, adding something like...

<a href="<?php echo $view->controller->getTopicLink($topic)?>"
                                <?php if (isset($selectedTopicID) && $selectedTopicID == $topic->getTreeNodeID()) { ?>
                                <?php } ?> ><?php echo $topic->getTreeNodeDisplayName()?></a>


but it doesn't work.

Does anyone know if that could be implemented by editing that file, and how?

daltro
 
andrew replied on at Permalink Best Answer Reply
andrew
Thanks – that's a great compliment. Glad you're enjoying the new version.

Here's how I would approach the problem.

1. First, turn off the overrides cache in Dashboard > System and Settings > Optimization > Cache and Speed Settings.

2. Next, create a new directory at application/blocks/page_title/templates/. Copy concrete/blocks/page_title/templates/byline.php into this directory. Since you turned off the overrides cache, the system will look into the application directory before looking into the concrete directory, and you'll be able to keep your custom changes separate from concrete5's internal code.

3. Now, you can make changes to byline.php for this new functionality. Here's a custom template that should get you started:

<?php  defined('C5_EXECUTE') or die("Access Denied.");
$dh = Core::make('helper/date'); /* @var $dh \Concrete\Core\Localization\Service\Date */
$page = Page::getCurrentPage();
$date = Core::make('helper/date')->formatDate($page->getCollectionDatePublic(), true);
$user = UserInfo::getByID($page->getCollectionUserID());
?>
<div class="ccm-block-page-title-byline">
    <h1 class="page-title"><?=$title?></h1>
    <span class="page-date">
    <? print $date; ?>
    </span>
    <? if (is_object($user)): ?>
    <span class="page-author">
    <? print $user->getUserDisplayName(); ?>
    </span>


It's basically the same as the byline template, but in order to show topics it grabs the custom attributes of the current page, and loops through them. A couple notes:

1. This assumes that you're using blog_entry_topics. This is a separate attribute from project_topics, etc... so this is doing some hard coding. You might consider making separate custom templates for the different areas of your site.

2. This assumes you always want to link up to the parent page.

3. This doesn't give you any CSS for the page-topics class applied to the span. You'll have to do that yourself.

Hope this helps!
daltro replied on at Permalink Reply
daltro
Thanks, andrew. It's done. Thank you very much, indeed.
andrew replied on at Permalink Reply
andrew
Good to hear!