17488 Posts in 4473 Topics by 1978 members
| Go to End | Next > | |
| Author | Topic: | 6026 Views |
-
Page Titles

1 August 2007 at 11:09am
There should be some area in the CMS where you can edit a default title "appendage". For example, if I'm building my site, I don't want the title of my page to be just "Home" - I might want it to be "Home | Bandit Website", and have that " | Bandit Website" appended to the end of every title within my site, rather than having to manually add it to each page.
Thoughts?
-
Re: Page Titles

1 August 2007 at 1:57pm Last edited: 1 August 2007 1:58pm
I agree.
Perhaps we have something in the _config.php like:
global $siteTitle;
$siteTitle = 'My cool site';Then, inside the code which generates <title></title> ($MetaTags) we include the global $siteTitle variable.
That's just a rough guess on how we could do it. Sam, perhaps you have some thoughts on this?
Cheers,
Sean -
Re: Page Titles

1 August 2007 at 2:00pm
My solution to this problem was to put it in the template.
In head of Page.ss I have:
[html]
<title>$Title.XML - $SiteName</title>$MetaTags(false)
[/html]
and in _config.php I put
$SiteName = "Nathan's Wondiferous Website";
Passing 'false' to $MetaTags is supposed to exclude the title, so you can put it in yourself.
Unfortunately, it seems to broken last I checked - you'll need to go into the MetaTags function in SiteTree and tell it to look for the strings 'true' and 'false' instead of booleans, since the template passes your false as a string. -
Re: Page Titles

1 August 2007 at 5:35pm Last edited: 1 August 2007 5:35pm
How about actually removing the <title> generation from the $MetaTags function, so a site developer has control over the <title> attribute themselves, as well as being able to include $MetaTags for <meta></meta>.
Thoughts?
Cheers,
Sean -
Re: Page Titles

1 August 2007 at 5:39pm
Yeah, that makes alot more sense to me...not so good for backwards compatability of templates, though.
-
Re: Page Titles

1 August 2007 at 5:48pm
I've noticed this behaviour with template designers, especially when they don't assume $MetaTags generates the <title> element of the page... Your idea seems the best, since it's backwards compatible. So you have to check for 'false', rather than simply false?
Cheers,
Sean -
Re: Page Titles

1 August 2007 at 6:01pm Last edited: 1 August 2007 6:02pm
I just changed the function to this:
public function MetaTags($includeTitle = 'true') {
$tags = "";
if($includeTitle == 'true') {
$tags .= "<title>" . Convert::raw2xml($this->MetaTitle ? $this->MetaTitle : $this->Title) . "</title>\n";
}
$tags .= "<meta name=\"generator\" http-equiv=\"generator\" content=\"SilverStripe 2.0 - http://www.silverstripe.com\" />\n";
$charset = ContentNegotiator::get_encoding();
$tags .= "<meta http-equiv=\"Content-type\" content=\"text/html; charset=$charset\" />\n";
if($this->MetaKeywords) {
$tags .= "<meta name=\"keywords\" http-equiv=\"keywords\" content=\"" . Convert::raw2att($this->MetaKeywords) . "\" />\n";
}
if($this->MetaDescription) {
$tags .= "<meta name=\"description\" http-equiv=\"description\" content=\"" . Convert::raw2att($this->MetaDescription) . "\" />\n";
}
return $tags;
}It's all in the first three lines - just treat $includeTitle as a string, and pre-set $tags to avoid errors. Although this way, you could do $MetaTags(oneonewasaracehorse) and it would work, too...
-
Re: Page Titles

2 August 2007 at 9:40am
I've changed the code to check for both boolean true and string 'true'. Thanks for this!
| 6026 Views | ||
| Go to Top | Next > |




