How do I enable inline field editing in SiteEdit when using an XSLT TBB?

眉间皱痕 提交于 2020-01-15 03:41:08

问题


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.


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/9667640/how-do-i-enable-inline-field-editing-in-siteedit-when-using-an-xslt-tbb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!