Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi ,
I'm trying to set the id of a div as follows
<div id=<umbraco:Macro Alias="SetContentID" runat="server"></umbraco:Macro>>
this should render as follows <div id="default">
but I dont know how to get the double quotes
thanks
<div>
<xsl:attribute name="id">
<umbraco:Macro Alias="SetContentID" runat="server" />
</xsl:attribute>
</div>
Hi Sajid
If you want to create the div-element in your template, and then use a macro to insert the id attribute, you should be able to do it like this:
In your template:
<div <umbraco:Macro Alias="SetContentID" runat="server"></umbraco:Macro>>
Then in your SetContentID xslt-file you should return something like this:
id="default"
You could create some different scenarios in your xslt-file using eg. a <xsl:choose> to determine what the id should be. Something like this:
<xsl:choose> <xsl:when test="something here">id="alternativeID"</xsl:when> <xsl:otherwise>id="default"</xsl:otherwise></xsl:choose>
/Kim A
Thanks Guys,
Kim your method works good.
heres my xslt:
<?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:template match="/"> <xsl:value-of select="$currentPage/backgroundImageID"/></xsl:template></xsl:stylesheet>
here's how i used in html:
<div id="<umbraco:Macro Alias='SetContentID' runat='server'></umbraco:Macro>">
I set backgroundImageID the on the doc type.
many thanks guys
>sajid
Good to hear that you got i solved Sajid.
But if your only want to output a textstring from the backoffice on the current page, you don't have to go through all the work of creating a XSLT-file/macro first. Then you can just do like this:
<div id="<umbraco:Item field='backgroundImageID' runat='server'></umbraco:Item>">
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
setting div id using xslt
Hi ,
I'm trying to set the id of a div as follows
<div id=<umbraco:Macro Alias="SetContentID" runat="server"></umbraco:Macro>>
this should render as follows <div id="default">
but I dont know how to get the double quotes
thanks
<div>
<xsl:attribute name="id">
<umbraco:Macro Alias="SetContentID" runat="server" />
</xsl:attribute>
</div>
Hi Sajid
If you want to create the div-element in your template, and then use a macro to insert the id attribute, you should be able to do it like this:
In your template:
Then in your SetContentID xslt-file you should return something like this:
You could create some different scenarios in your xslt-file using eg. a <xsl:choose> to determine what the id should be. Something like this:
/Kim A
Thanks Guys,
Kim your method works good.
heres my xslt:
<?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:template match="/">
<xsl:value-of select="$currentPage/backgroundImageID"/>
</xsl:template>
</xsl:stylesheet>
here's how i used in html:
<div id="<umbraco:Macro Alias='SetContentID' runat='server'></umbraco:Macro>">
I set backgroundImageID the on the doc type.
many thanks guys
>sajid
Good to hear that you got i solved Sajid.
But if your only want to output a textstring from the backoffice on the current page, you don't have to go through all the work of creating a XSLT-file/macro first. Then you can just do like this:
/Kim A
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.