Alvin Reyes
Alvin Reyes

Reputation: 2887

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.

Upvotes: 1

Views: 528

Answers (3)

Quirijn
Quirijn

Reputation: 3547

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!

Upvotes: 3

Mihai Cădariu
Mihai Cădariu

Reputation: 2407

Will's article refers to SiteEdit only (if I'm not mistaken). Your question is about a generic mechanism on 'including DCPs from a RTF field'.

Allowing other DCPs to be referred to from RTF is, in my view, not very kosher. I would even go as to say it is bad practice. I would avoid mixing content with layout (in the context of DCPs). I think that's something that should be done in a template or via metadata.

I think (D)CPs should be placed on a Page or queried for using some kind of metadata. I would probably prefer to have some taxonomies to tag a DCP against, then in another Component (let's call it a Control Component) you would specify some kind of criteria cocktail regarding which DCPs you want to query and display on the Page. The template will then generate some code (e.g. a custom tag) that would be executed on the Content Delivery side.

Alternatively to your request, maybe a list of links would make more sense for the authors.

Finally, to go back to your requirement, if you choose to go ahead with DCPs in RTF, then I guess it's just a matter of finding a naming convention on how to 'point' to the DCPs from RTF. One possibility would be to use a specially crafted Component Link (maybe with some specific target attribute) that a C# TBB would understand to parse out and replace with a <tridion:ComponentPresentation.../> call. I would use Component Links in an RTF because these links are maintained for integrity, consistency, porting, etc...

Upvotes: 1

johnwinter
johnwinter

Reputation: 3624

Not sure I understand fully the question but here goes:

If a user enters a component link within a rich text field depending on your configuration (type of component presentation and output type) the value will with resolved, most likely to a .

It might be worth having your own c# building block resolve to your own format, then write your own tcdl extension to parse it.

If you're trying to put Tridion component presentation inside component presentations.. I think your data model is a bit (lot!) messed up :)

Upvotes: 1

Related Questions