3

I'm trying to replace a link with an iframe in a rich text field but I can't get it to work. Somehow, it is not accepting the iframe-tag, or other tags for that matter. In the end, I'm trying to achieve transforming a link to a Youtube video to an embedded iframe to the same url.

Below is the filtering XSLT that I have specified for my rich text field. It should match all a-elements, and replace them with an iframe to google and also show the text "The link should have been converted to an iframe!". Currently what is happening is that the text is shown, but the iframe is nowhere to be seen. I have tested with other tags as well, for example "strong", but it never gets through either.

<stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!--    changed by carl-david:   <output omit-xml-declaration="yes" method="xml" cdata-section-elements="script"></output> -->
<output method="html" indent="yes"></output>
<template match="/ | node() | @*">
    <copy>
        <apply-templates select="node() | @*"></apply-templates>
    </copy>
</template>
<template match="a">
    <iframe src="http://www.google.com"></iframe>
    <text>The link should have been converted to an iframe!</text>
</template>
<template match="*[      (self::br or self::p or self::div)     and      normalize-space(translate(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;     and      not(@*)     and      not(processing-instruction())     and      not(comment())     and      not(*[not(self::br) or @* or * or node()])     and      not(following::node()[not(         (self::text() or self::br or self::p or self::div)        and         normalize-space(translate(., &apos; &apos;, &apos;&apos;)) = &apos;&apos;        and         not(@*)        and         not(processing-instruction())        and         not(comment())        and         not(*[not(self::br) or @* or * or node()])       )])     ]">
    <!-- ignore all paragraphs and line-breaks at the end that have nothing but (non-breaking) spaces and line breaks -->
</template>
<template match="br[parent::div and not(preceding-sibling::node()) and not(following-sibling::node())]">
    <!-- Chrome generates <div><br/></div>. Renders differently in different browsers. Replace it with a non-breaking space -->
    <text> </text>
</template>

Any idea of why it doesn't allow me to create new tags?

  • what version of SDL Tridion are you using? – Bart Koopman Apr 29 '13 at 10:50
  • @BartKoopman: 2013 – Calle Apr 29 '13 at 11:04
  • You might want to consider reporting this to SDL Tridion Customer Support, because your XSLT should work by the looks of it. – Bart Koopman May 1 '13 at 6:28
3

You need to include new tags for new-inline-tags on TcmXHTML.config file

Location:

%TRIDION_HOME%\WebUI\Core\Controls\FormatArea\TcmXhtml\TcmXHTML.config

Example:

new-inline-tags: iframe XYZ ABC PQR

Update:

Try replacing this

<template match="a">
    <iframe src="http://www.google.com"></iframe>
    <text>The link should have been converted to an iframe!</text>
</template>

with this

<template match="a">
    <element name="strong">
        <text>The link should have been converted to an strong!</text>
    </element>
</template>
  • Doesn't seem to work. Maybe it's needed though, but as I said it doesn't work for "<strong>" either, which is a tag that is accepted by the RTF when doing normal editing. – Calle Apr 29 '13 at 11:06
  • @Calle: Ok you are saying strong tag is not even working. Can you try above mentioned template? – Siva Charan Apr 29 '13 at 11:40
  • Great, that works! So the key was to use the <element>-tag, thanks! – Calle May 2 '13 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.