If you've got <head runat="server"> then you should be able to use an XSLT extension to set the <title> and find the meta description control/tag (easier to locate if you give it an ID and runat=server).
Otherwise you could try putting a macro in the <head> and generate/populate the title/meta-description from there, (which you'd probably already thought of).
I can't set the title in a macro in the header, as the content is decided by something going on further down the page. Usually you have the TITLE in your master page, and I want to change it to something else more or less dependant on the actual doc type. Fx. @nodeName is okay for all regular pages, but on all product pages I want the TITLE to be "Buy a @nodeName for only xxx DKK".
So I guess I should try and write and XSLT extension for this, if one doesn't exist already.
i'm pretty new at everything and i'm doing ok but something i just can't get to work i'm trying to set up a xslt file so my page title changes, but it wont grab the info out of my doc
this is my xslt file, somhow the information i put in at the tab sitename in my content manager doesn't appear in the page title:
@David: You're calling the siteName alias on both $homepageNode and on $currentPage, and in the latter case, it'll only work when you are actually on the homepage (which is then the $currentPage).
It looks like your example is a mix of pre-4.5 and post-4.5 XML schema, but on the new schema, I'd to this:
<!--If a node has content for the seoTitle property, output that--> <xsl:template match="*[normalize-space(seoTitle)]" mode="title" priority="1"> <xsl:value-of select="seoTitle"/> </xsl:template>
<!--If we're on the homepage, output the sitename and the site description--> <xsl:template match="HomePage" mode="title"> <xsl:value-of select="concat(siteName, ' - ', siteDescription)"/> </xsl:template>
<!--For all other pages, output the sitename and the name of the current page--> <xsl:template match="*" mode="title"> <xsl:value-of select="concat(ancestor-or-self::HomePage/siteName, ' - ', @nodeName)"/> </xsl:template>
Setting TITLE and META DESCRIPTION from macro
Hi everyone,
is is possible to set the page title and meta description from an XSLT macro further down the page?
I know I've seen the trick somewhere, just can't seem to find it again.
Best regards,
Soeren Sprogoe
Hi Soeren,
If you've got <head runat="server"> then you should be able to use an XSLT extension to set the <title> and find the meta description control/tag (easier to locate if you give it an ID and runat=server).
Otherwise you could try putting a macro in the <head> and generate/populate the title/meta-description from there, (which you'd probably already thought of).
Cheers, Lee.
Hi Lee,
thanks for your reply.
I can't set the title in a macro in the header, as the content is decided by something going on further down the page. Usually you have the TITLE in your master page, and I want to change it to something else more or less dependant on the actual doc type. Fx. @nodeName is okay for all regular pages, but on all product pages I want the TITLE to be "Buy a @nodeName for only xxx DKK".
So I guess I should try and write and XSLT extension for this, if one doesn't exist already.
Best regards,
Soeren Sprogoe
You should be able to write this as a XSLT Macro,
This could use xsl:choose, when parent id=shop section, then get the the title and also the price.
Should be really simple and no need for a custom extension.
/L
hi
i'm pretty new at everything and i'm doing ok but something i just can't get to work
i'm trying to set up a xslt file so my page title changes, but it wont grab the info out of my doc
this is my xslt file, somhow the information i put in at the tab sitename in my content manager doesn't appear in the page title:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="homepageNode" select="$currentPage/ancestor::root/HomePage"/>
<xsl:template match="/">
<title>
<xsl:choose>
<xsl:when test="string-length($currentPage/data[@alias='seoTitle']) > 0">
<xsl:value-of select="$currentPage/data[@alias='seoTitle']"/>
</xsl:when>
<xsl:when test="$homepageNode/@id = $currentPage/@id">
<xsl:value-of select="$homepageNode/data[@alias='siteName']"/> - <xsl:value-of select="$homepageNode/data[@alias='siteDescription']"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$currentPage/data[@alias='siteName']"/> | <xsl:value-of select="$currentPage/@nodeName"/>
</xsl:otherwise>
</xsl:choose>
</title>
</xsl:template>
</xsl:stylesheet>
Please help :D
@David: You're calling the siteName alias on both $homepageNode and on $currentPage, and in the latter case, it'll only work when you are actually on the homepage (which is then the $currentPage).
It looks like your example is a mix of pre-4.5 and post-4.5 XML schema, but on the new schema, I'd to this:
@dan
thanks a million, this works like a charm.
now i can finally go on with the rest.
Thanks again
is working on a reply...