Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ansar 181 posts 291 karma points
    Jul 19, 2011 @ 13:13
    Ansar
    0

    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

  • Ansar 181 posts 291 karma points
    Jul 19, 2011 @ 13:44
    Ansar
    0

    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")'>


  • Kim Andersen 1447 posts 2196 karma points MVP
    Jul 19, 2011 @ 14:46
    Kim Andersen
    0

    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

  • Ansar 181 posts 291 karma points
    Jul 20, 2011 @ 08:19
    Ansar
    0

    Hi Kim.. yes using parameter checking also a nice idea.. Thanks :)

Please Sign in or register to post replies

Write your reply to:

Draft