Site name disappears in title when using custom title attribute

Permalink 1 user found helpful
Hi All

Question about custom title tags....

When I don't set a custom title tag in the properties section of the page, the title tag prints out "My site :: My Page Title". Which is fine.

But whenever I add a title to the custom title attribute and save, the title tag now just reads "My Custom Page Name". It does not include the site name.

Any recommendations?

Thanks

iShiva

 
iShiva replied on at Permalink Reply
Anything on this topic?

Any help is appreciated.
arrestingdevelopment replied on at Permalink Best Answer Reply
arrestingdevelopment
iShiva,

This isn't a complete answer... but it's a start. You could copy the /concrete/elements/header_required.php file to /elements/header_required.php. Then edit that new file. If you look through it, around line 25 there's an if-else statement that looks at whether or not the "Meta Title" field has been filled and outputs an HTML title tag containing just that if it is. Editing this to be more like the "else" part of that statement might work.... so try having it read something like (this is UN-tested code):
if ($akt) { 
   $pageTitle = $akt; 
   ?><title><?php  echo sprintf(PAGE_TITLE_FORMAT, SITE, $pageTitle)?></title>
<?php  } else {

might do the trick.

Hope that helps!

- John
iShiva replied on at Permalink Reply
Hi John

Thanks for the response. I got it working with your assistance.

Here was the initial code (line 25 in header_required.php):

<?php 
if ($akt) { 
   $pageTitle = $akt; 
   ?><title><?php  echo htmlspecialchars($akt, ENT_COMPAT, APP_CHARSET)?></title>
<?php  } else { 
   $pageTitle = htmlspecialchars($pageTitle, ENT_COMPAT, APP_CHARSET);
   ?><title><?php  echo sprintf(PAGE_TITLE_FORMAT, SITE, $pageTitle)?></title>
<?php  } ?>


I changed it to this (basically just copied/pasted the 'else' title tag output:

<?php 
if ($akt) { 
   $pageTitle = $akt; 
   ?><title><?php  echo sprintf(PAGE_TITLE_FORMAT, SITE, $pageTitle)?></title>
<?php  } else { 
   $pageTitle = htmlspecialchars($pageTitle, ENT_COMPAT, APP_CHARSET);
   ?><title><?php  echo sprintf(PAGE_TITLE_FORMAT, SITE, $pageTitle)?></title>
<?php  } ?>


And now everything is working.

Thanks much!

iShiva
arrestingdevelopment replied on at Permalink Reply
arrestingdevelopment
So glad that worked and no things are as you wanted them!

- John
Pritam replied on at Permalink Reply
I am using Concrete5 5.6.1.2 and am facing the same issue, I tried to follow iShiva's suggestions, however the header_required.php seems to do it differently than the code that worked for you. Here's the code for the header_required.php in 5.6.1.2http://pastie.org/8671183

Would appreciate if someone could point me in the right direction.
Temposaur replied on at Permalink Reply
Temposaur
Easiest way is just writing the site name manually to the custom title attribute.

It isn't the best solution, but it's the easiest and fastest. No coding needed.
Pritam replied on at Permalink Reply
Thanks I solved this by adding the else statement on line 28

else { $pageTitle = sprintf(PAGE_TITLE_FORMAT, SITE, $pageTitle); }