Copied to clipboard

Flag this post as spam?

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


  • Pavel Kivalin 9 posts 29 karma points
    Jun 07, 2010 @ 20:33
    Pavel Kivalin
    0

    Output javascript from xslt

    Hi all. I am newbie in Umbraco.

    I have richtexteditor field in my datatype. I am write in this field code yandex metrika.

    For example:

    <script src="//mc.yandex.ru/metrika/watch.js" type="text/javascript"></script>
    <div style="display:none;"><script type="text/javascript">
    try { var yaCounter1121901 = new Ya.Metrika(1121901); } catch(e){}
    </script></div>
    <noscript><div style="position:absolute"><img src="//mc.yandex.ru/watch/1121901" alt="" /></div></noscript>

     

    In my xslt file i try output this is code:

    <xsl:value-of select="$node/data[@alias = 'YandexMetrika']"/>   


    but I do not get right result. Can you tell me where i'm wrong?

     

    Sorry for my bad english.

  • Pavel Kivalin 9 posts 29 karma points
    Jun 07, 2010 @ 21:34
    Pavel Kivalin
    0

    And i use <xsl:output method="xml" omit-xml-declaration="yes"/>

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jun 07, 2010 @ 22:13
    Lee Kelleher
    0

    Hi Pavel,

    Personally I wouldn't use the rich-text editor to insert JavaScript snippets, TinyMCE tries to format the code - I've had headaches with it!

    If the property is only used for the JavaScript, then you could change the data-type to a "Textbox Multiple", (in your document-type), as that will sort the JavaScript literally.

    Your XSLT seems fine.

    Let us know how you get on.

    Cheers, Lee.

  • Kevin Farrow 46 posts 67 karma points
    Jun 07, 2010 @ 22:18
    Kevin Farrow
    0

    Try adding  disable-output-escaping="yes"  i.e.

    <xsl:value-of select="$node/data[@alias = 'YandexMetrika']" disable-output-escaping="yes" />

    Regards,
    Kevin

  • Pavel Kivalin 9 posts 29 karma points
    Jun 07, 2010 @ 22:20
    Pavel Kivalin
    0

    Hi again. Thank you for your answers. I solve problem with append <xsl:comment> block.

    <xsl:comment>
            <xsl:value-of select="$node/data[@alias = 'YandexMetrika']" disable-output-escaping="yes"/>   
     </xsl:comment>

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Jun 07, 2010 @ 22:38
    Lee Kelleher
    1

    Hi Pavel,

    I'm not sure putting the code within a comment block is going to solve your problem - the JavaScript wont run on in the web-browser, (because it is commented-out!)

    Try removing the <xsl:comment> blocks, and leaving in the "disable-output-escaping=yes", and see if that works?

    Cheers, Lee.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jun 07, 2010 @ 23:55
    Jan Skovgaard
    1

    Hi Pavel

    I really think you should use the "multiple text" datatype instead of using the RTE datatype for this. I think it's giving less of a headache since tinyMce will not bug you. You will just get the text. You should use the disable-output-escaping="yes" as Lee is saying when you fetch the data.

    /Jan

  • Pavel Kivalin 9 posts 29 karma points
    Jun 08, 2010 @ 06:29
    Pavel Kivalin
    0

    Oh. I'm wrong. You rights, sorry. Thank you!

Please Sign in or register to post replies

Write your reply to:

Draft