nikola Posted November 1, 2011 Share Posted November 1, 2011 As you might now it, Google search engine uses <title></title> tag as very relevant source of information about your web site. Sometimes it's good to use "breadcrumbs" in <title></title> tag to define structure of categories and such. If you want to use this kind of <title></title> tag instead of regular page title, then you could do the following: <title><?php $root = $pages->get('/'); foreach($page->parents()->remove($root)->append($page)->reverse() as $parent) { echo "{$parent->title} - "; } echo "COMPANY NAME"; ?></title> Replace "COMPANY NAME" with the name of your company etc. 1 Link to comment Share on other sites More sharing options...
Adam Kiss Posted November 1, 2011 Share Posted November 1, 2011 It's cool tip – with some cool PageArray modification aswell. Regarding titles itself; I would never do this, unless it would make total sense for visitor (e.g. some kind of eshop, where I can imagine something like 'Yamaha XZ-200 – Electronic keyboards – keyboards – products) – that looks okay. Otherwise, I am more of fan of 'copywrite for people, not google'. Link to comment Share on other sites More sharing options...
ryan Posted November 1, 2011 Share Posted November 1, 2011 Good tip! Here's another way to do the same thing (using the slice method to trim off home): <title><?php foreach($page->parents()->append($page)->slice(1)->reverse() as $parent) { echo "{$parent->title} - "; } echo "COMPANY NAME"; ?></title> 1 Link to comment Share on other sites More sharing options...
thomassausen Posted January 30, 2013 Share Posted January 30, 2013 Thanks. And if you want this title on homepage: <title>Company Name - {$parent->title}</title> And on all other sites: <title>{$parent->title} - Company Name</title> ? 1 Link to comment Share on other sites More sharing options...
SiNNuT Posted January 31, 2013 Share Posted January 31, 2013 With some conditional logic like $homepage = $pages->get('/'); if($page === $homepage) { echo "<title>Company Name - {$parent->title}</title>"; } else { echo "<title>{$parent->title} - Company Name</title>"; } 1 Link to comment Share on other sites More sharing options...
ryan Posted January 31, 2013 Share Posted January 31, 2013 Another way to check for homepage is just if the $page->id === 1; because the homepage always has an ID of 1. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now