且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 XSLT TBB 时如何在 SiteEdit 中启用内联字段编辑?

更新时间:2023-11-09 16:16:52

如果您将 XSLT TBB 与 XSLT Mediator 一起使用,您将需要手动包装要为 SiteEdit 启用的字段,以便它们出现在你的模板.考虑使用类似于以下代码的 XSLT 包装您的字段:

</xsl:for-each></xsl:模板></xsl:stylesheet>

此代码循环遍历每个嵌入的段落字段,并输出文本字段值,并使用适当的 SiteEdit TCDL 语法对其进行包装.

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.

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.