Check if a macro is added to the rich text editor from XSLT
Hi all,
Is there anyway I can check if a macro is added to the rich text editor from XSLT.
I have an image gallery macro using XSLT.. admins can add it through RTE.. I need to check whether the admin added the macro and if not, add it programatically from XSLT...
I am looking for something like <xsl:choose> <xsl:when test="isMAcroAdded($currentPage/bodyText, 'galleryMacro') = false()"> <xsl:call-template name="createGallery"> <xsl:with-param name="parent" select="$currentPage" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$currentPage/bodyText" /> </xsl:otherwise> </xsl:choose>
Another way you could do this without having to create the extension, would be to set a parameter on the macro in the back office called something like fromTemplate. Then when you insert the macro through one of your tempaltes you could set the fromTemplate="1". Then inside your xslt, you could check if the fromTemplate-parameter was equal to 1 or just empty. If it's empty you'd know thtat the macro in inserted though the richtext editor.
Check if a macro is added to the rich text editor from XSLT
Hi all,
Is there anyway I can check if a macro is added to the rich text editor from XSLT.
I have an image gallery macro using XSLT.. admins can add it through RTE..
I need to check whether the admin added the macro and if not, add it programatically from XSLT...
I am looking for something like
<xsl:choose>
<xsl:when test="isMAcroAdded($currentPage/bodyText, 'galleryMacro') = false()">
<xsl:call-template name="createGallery">
<xsl:with-param name="parent" select="$currentPage" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$currentPage/bodyText" />
</xsl:otherwise>
</xsl:choose>
Regards,
Ansar
I have added one C# function in XSLT to solve it :)
This is what I did - if it helps anyone
added following C# function
<msxml:script implements-prefix="macroLib" language="C#">
<msxml:assembly name="System.Web"/>
<msxml:using namespace="System.Web"/>
<![CDATA[
public bool isMacroExist(string content, string alias)
{
return content.Contains(string.Format("macroAlias=\"{0}\"", alias));
}
]]>
</msxml:script>
and simply called it <xsl:when test='macroLib:isMacroExist($currentPage/pageContent, "ImageGallery")'>
Hi Anz
Another way you could do this without having to create the extension, would be to set a parameter on the macro in the back office called something like fromTemplate. Then when you insert the macro through one of your tempaltes you could set the fromTemplate="1". Then inside your xslt, you could check if the fromTemplate-parameter was equal to 1 or just empty. If it's empty you'd know thtat the macro in inserted though the richtext editor.
Just a suggestion :)
/Kim A
Hi Kim.. yes using parameter checking also a nice idea.. Thanks :)
is working on a reply...