Search code examples
tridion

Including dynamic component presentations within a rich text field?


Template code can transform TCDL tags into the appropriate content delivery version.

Templates can output:

<tcdl:Link .../>
<tcdl:ComponentPresentation .../>

Delivery side would get tags in this format:

<tridion:ComponentLink ... />
<tridion:ComponentPresentation ... />

Question: Is it possible to let a content author enter such a dynamic component presentation (DCP) in a rich text field format area? And if so, is a particular format preferred and how should we publish the linked-to DCP?

Edit: added context and changed link to Will's article.

Alternatively could I mimic some syntax similar to this approach from Will Price specifically for SiteEdit using DWT and C# assembly help.


Solution

  • I agree with John, I would implement this as a component link in the RTF. But I wouldn't use any template code, I would instead override Tridion's LinkTagHandler. In the doEndTag method, you can check if you would want to resolve the linked component as a regular dynamic link (in which case you just call the super class), or if you want to insert the DCP there (in which case you can call the ComponentPresentationTagHandler).

    You can then configure your taghandler, overriding the Tridion default LinkTagHandler (you can do this in the cd_deployer_conf.xml). Mind you, I haven't tried any of this, but I don't see why it wouldn't work.

    To configure your custom tag handler, add the following to the cd_deployer_conf.xml:

    <TCDLEngine>
        <Properties>
            <!-- keep whatever you have in this section! -->
        </Properties>
        <Tags>
            <Tag Namespace="tcdl" Name="ContentHeader"><Handler Class="com.tridion.tcdl.tags.ContentHeaderTagHandler"/></Tag>
            <Tag Namespace="tcdl" Name="Link"><Handler Class="com.mycompany.tridion.extensions.CustomTagHandler"/></Tag>
            <Tag Namespace="tcdl" Name="Link"><Handler Class="com.tridion.tcdl.tags.DynamicLinkInfoTracker"/></Tag>
            <Tag Namespace="tcdl" Name="TargetGroup"><Handler Class="com.tridion.tcdl.tags.TargetGroupTagHandler"/></Tag>
            <Tag Namespace="tcdl" Name="ComponentPresentation"><Handler Class="com.tridion.tcdl.tags.ComponentPresentationTagHandler"/></Tag>
            <Tag Namespace="tcdl" Name="FirstLine"><Handler Class="com.tridion.tcdl.tags.FirstLineTagHandler"/></Tag>
            <Tag Namespace="tcdl" Name="IncrementTrackingKey"><Handler Class="com.tridion.tcdl.tags.IncrementTrackingKeyTagHandler"/></Tag>
            <Tag Namespace="tcdl" Name="PositionMarker"><Handler Class="com.tridion.tcdl.tags.PositionMarkerTagHandler"/></Tag>
            <Tag Namespace="tcdl" Name="ContextProperty"><Handler Class="com.tridion.tcdl.tags.ContextPropertyTagHandler"/></Tag>
            <Tag Namespace="tcdl" Name="Dependency"><Handler Class="com.tridion.tcdl.tags.DependencyTagHandler"/></Tag>
            <Tag Namespace="tcdl" Name="Comment"><Handler Class="com.tridion.tcdl.tags.CommentTagHandler"/></Tag>
            <Tag Namespace="tcdl" Name="TaxonomyControl"><Handler Class="com.tridion.tcdl.tags.TaxonomyTagHandler"/></Tag>
        </Tags>
    </TCDLEngine>
    

    One important note: if you decide to override any of the built-in tag handlers, you need to specify all of them!