2

I am working on SDL Tridion 2011 SP1 with the XSLT Mediator from SDL Tridion World and SiteEdit 2009 SP3. I have created XSLT TBB, and enabled Inline editing for Component Template, enabled SiteEdit in the Page Template. I have created the page using that and published it.

But SiteEdit is not being enabled for each field. When I looked at the source of page preview, it has only one span tag for whole component. But usually if SiteEdit is enabled for the component we should have span tag for each field.

I am stuck at this point. I have created XSLT TBB using XSLT mediator.

Can anyone suggest whether we can enable SiteEdit in a Compound Template using an XSLT TBB? If it can be done, suggest me the steps to do it.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Patan
  • 17,073
  • 36
  • 124
  • 198

2 Answers2

4

If you are using XSLT TBBs with the XSLT Mediator, you will need to manually wrap the fields you want to enable for SiteEdit so that they appear in the output of your template. Consider wrapping your fields with XSLT using code similar to this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
        <xsl:for-each select="//*[local-name()='paragraph']">
            <div>
                <tcdl:ComponentField name="paragraph[{position() -1}].text" index="0">
                    <xsl:apply-templates select="./*[local-name()='text']"/>
                </tcdl:ComponentField>
            </div>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

This code loops through each embedded paragraph field, and outputs the text fields value, and wraps it with the appropriate SiteEdit TCDL syntax.

Chris Summers
  • 10,153
  • 1
  • 21
  • 46
  • can you provide the name space for TCDL prefix. – Patan Mar 12 '12 at 14:07
  • Well it does not really have one to be honest as it is not technically an XML element (TCDL is a environment neutral tagging syntax). However, when using it in XSLT, the tcdl is indeed interpreted as an XML namespace prefix, and will cause the XML parser to fail if not declared. As such you can use pretty much use any namespace prefix like xmlns:tcdl="some_random_string". But be consistent in your implementation, I tend to use xmlns:tcdl="tcdl" or xmlns:tcdl="none". Some developers use xmlns:tcdl="http://www.tridion.com/ContentDelivery/5.3/TCDL". Just pick one and stick with it. – Chris Summers Mar 12 '12 at 14:13
  • can you explain how do it for simple field which is not embedded one. – Patan Mar 12 '12 at 14:52
4

It is up to the templates (XSLT, DWT, VBscript or whatever technology you use) to generate an element around every field.

 <span>
     <!-- Start SiteEdit Component Field: { ... } -->
     This is the value of the field
 </span>

Normally you'll call RenderComponentField in your DWT, which will mark every field with a <tcdl:ComponentField> element. This element is then translated into the correct element (a span in the example above) by the "Enable inline editing" TBB.

So if you generate the HTML from your XSLT, make sure you either:

  • call RenderComponentField for the field OR
  • output <tcdl:ComponentField yourself OR
  • output the wrapping element and <!-- Start SiteEdit Component Field yourself
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Can you please elaborate on "output the wrapping element and – Patan Mar 12 '12 at 13:55
  • 1
    See my example, it has a complete XSLT sample – Chris Summers Mar 12 '12 at 13:57
  • @Chris Summers can you explain how do it for simple field which is not embedded one. – Patan Mar 12 '12 at 14:51
  • 1
    @Muzmil - I suggest you use the out-of-the box DWT templates and use the RenderComponentField() methods that Frank suggested until you are more familiar with the required syntax. Once you know what you are really trying to produce, the XSLT method will become very clear. Alternatively take an good SDL Tridion training course. Stack Overflow is really for asking programming questions, not a training platform. Sorry I can't be of more direct help. Feel free to contact me directly if you need help finding training. – Chris Summers Mar 12 '12 at 15:50