How to display the page name/title as an H1 heading
Permalink
Need to display the name of the page as an H1 heading on the page by default -- I thought this would be automatic but it doesn't seem to be...
Basically the equivalent of <?php the_title(); ?> in WordPress.
If this is a dumb question I apologize... seems utterly basic and I'm sure it's super-simple, but I just can't seem to figure it out...
Thanks.
dustin
Basically the equivalent of <?php the_title(); ?> in WordPress.
If this is a dumb question I apologize... seems utterly basic and I'm sure it's super-simple, but I just can't seem to figure it out...
Thanks.
dustin
Thanks very much!
I did find a solution, just a moment ago, here:http://www.concrete5.org/community/forums/customizing_c5/page_title...
It's only slightly different from yours, but this code snippet will display the meta title if there is one, otherwise display the "collectionName" which is equivalent to the page title:
Am I the only one who finds it odd that the page name isn't displayed on the page as an H1 by default?? Ah well.
I did find a solution, just a moment ago, here:http://www.concrete5.org/community/forums/customizing_c5/page_title...
It's only slightly different from yours, but this code snippet will display the meta title if there is one, otherwise display the "collectionName" which is equivalent to the page title:
Am I the only one who finds it odd that the page name isn't displayed on the page as an H1 by default?? Ah well.
Yeah, that will technically work, however, meta_title was not intended to work in this way. If you look in the /concrete/elements/header_required.php you will notice that it is meant to override the <title> in the HTML <head>.
You could potentially step on your toes down the road, so if having two different page names is necessary then I'd suggest making a new page attribute and use that as an override.
You could potentially step on your toes down the road, so if having two different page names is necessary then I'd suggest making a new page attribute and use that as an override.
<?php $strName = trim($c->getAttribute('override_page_attribute')); if(strlen($strName) == 0) $strName = $c->getCollectionName(); ?> <h1><?php echo htmlspecialchars($strName), ENT_QUOTES, 'UTF-8'); ?></h1>
Thanks, good to know.
For what I need your code works perfectly, so I'll just stick with that instead.
For what I need your code works perfectly, so I'll just stick with that instead.
You could theorectially place this in the SITE_ROOT/themes/yourthemefolder/elements/header.php file, but then it would appear in system pages and the home page. Keeping it in your template files gives you a bit more control.