Since it's an alternative template then the context used in the XSLT is still the one for $currentPage, which will then just give you the properties from your "page" and not your "templateName" alternative template.
I'm not sure if this works but perhaps it's possible to check the value returned by the @template attribute in the returned XML. It might display the template id of the alternative template...but again...I'm not sure but could be worth the try. Because if it's different then you can make some logic to handle the title and meta descriptions accordingly.
Shouldn't be a big problem - you have access to the actual URL via the Server Variables, and you know all the possibilities of template names, so something like this should help you get going:
Please note that this is the simplest way - not good if you need to check more than a few aliases - it doesn't cater for the situation where your altTemplate is named "contact" and you visit the page "/contacts/contact" - but if you need these, it can of course be extended.
Many thanks for the quick advice but on further consideration we've decided to dump the use of altTemplate altogether in sections where SEO is important.
If we kept them I'd have to fudge the titles, level and meta data for pages that effectively dont actually exist. The problem we're having is in using altTemplate a huge section of our site in the Google index has duplicates and we're worried about how this is affecting ranking.
So i'm gonna create a bunch of child doctypes for our content using altTemplates instead. It's autogenerated stuff like; related news, related publications etc.
duplicates wont matter if you use canonical tags Using Chriztians code above you could output a canonical tag which states where the content which should get the SEO juice lives.
get directory based url in XSLT for altTemplate
Does anyone know if it's possible to get the altTemplate name for a URL in an XSLT macro?
I'm using directory URLs so the format is...
http://domain.com/page/templateName
as opposed to...
http://domain.com/page?altTemplate=templateName
The reason I ask is for SEO, I want to be able to provide a different <title> in the <head> from the main document.
Martin.
Hi Martin
Since it's an alternative template then the context used in the XSLT is still the one for $currentPage, which will then just give you the properties from your "page" and not your "templateName" alternative template.
I'm not sure if this works but perhaps it's possible to check the value returned by the @template attribute in the returned XML. It might display the template id of the alternative template...but again...I'm not sure but could be worth the try. Because if it's different then you can make some logic to handle the title and meta descriptions accordingly.
Looking forward to hearing from you.
/Jan
Hi Martin,
Shouldn't be a big problem - you have access to the actual URL via the Server Variables, and you know all the possibilities of template names, so something like this should help you get going:
Please note that this is the simplest way - not good if you need to check more than a few aliases - it doesn't cater for the situation where your altTemplate is named "contact" and you visit the page "/contacts/contact" - but if you need these, it can of course be extended.
/Chriztian
Do'h! Of course! I really should have thought of that - Too much vacation mode...:D
/Jan
Hi all
Many thanks for the quick advice but on further consideration we've decided to dump the use of altTemplate altogether in sections where SEO is important.
If we kept them I'd have to fudge the titles, level and meta data for pages that effectively dont actually exist. The problem we're having is in using altTemplate a huge section of our site in the Google index has duplicates and we're worried about how this is affecting ranking.
So i'm gonna create a bunch of child doctypes for our content using altTemplates instead. It's autogenerated stuff like; related news, related publications etc.
Martin.
duplicates wont matter if you use canonical tags
Using Chriztians code above you could output a canonical tag which states where the content which should get the SEO juice lives.
<link rel="canonical" href="http://yoursite/the-real-page-is-actually-here" />
is working on a reply...