Hi Guys,
I've added default global Meta Tags by using the Homepage Meta Tags as the default set, then only replacing them if individual meta tags are actually specified for that page. So, if most pages have no meta tags set tehn the homepage set will be used as default but if one of the pages has a different title, or description or keywords it will use them.
You can have the correct page title appear in the default set on each individual page. So, if a page has left any Meta tags blank it actually uses the default set (homepage tags) PLUS the actual page title. eg. About Us ›› The ABC Company Website
To do this you need to add a simple function to your Page_Controller in Page.php:
function GetHomePage(){
return DataObject::get("HomePage");
}
Then, on the main Page.ss template call your Meta Tags like so:
<title><% if MetaTitle %>$MetaTitle<% else %>$Title » <% control GetHomePage %>$MetaTitle<% end_control %><% end_if %> </title>
<meta name="title" content="<% if MetaTitle %>$MetaTitle<% else %>$Title » <% control GetHomePage %>$MetaTitle<% end_control %><% end_if %>" />
<meta name="description" http-equiv="description" content="<% if MetaDescription %>$MetaDescription<% else %>$Title <% control GetHomePage %>$MetaDescription<% end_control %><% end_if %>" />
<meta name="keywords" http-equiv="keywords" content="<% if MetaKeywords %>$MetaKeywords<% else %>$Title <% control GetHomePage %>$MetaKeywords<% end_control %><% end_if %>" />
Hope this helps!
ps. By default Silverstripe populates the MetaTitle with the page title, so I've included the Default Title from the Homepage after it.