Patan
Patan

Reputation: 17893

how to add the custom elements in the RTF field of a component in SDL Tridion 2011 Sp1

I want to add custom elements in the source of a Rich Text field in SDL Tridion. Is there any chance to add them by changing the XSL filtering in the Schema?

Example:

I have a RTF field "text" in SDL Tridion. I want to add something like this:

<text>
    <customelement>the text added through the custom element</customelement>
</text>

Can somebody help me on this?

Thanks.

Upvotes: 2

Views: 1106

Answers (3)

Kah Tang
Kah Tang

Reputation: 1674

I'm assuming you're trying to add some HTML5 element in your rich text field.

If you don't want to modify any Tridion installation files, which is something you should try to avoid at all times you could try the following:

  • Include a CSS class in your rich text field options.
  • Let the users put the css class on a div, span or anchor tag in your rich text field.
  • On the front-end with some magic Javascript and jQuery you could try to change the element to the custom element you would like.

Upvotes: 4

Dominic Cronin
Dominic Cronin

Reputation: 6201

It is probably not necessary to do this. I suspect you should be focussing on your templated output instead.

The standard way for Tridion to store your data in an RTF is as XML in the XHTML namespace. This does not mean that your output needs to comply with this format, any more than the output from a plain text field would need to be plain text.

If you want to have special kinds of data within an RTF field, I would suggest that you use a standard XHTML element, and configure a custom style sheet so that the end users can select the element, and then apply the "specialness" by selecting a class. This is probably a much nicer user experience than having to edit the source tab.

In your templating, you can simply transform these elements into your desired output. I'd suggest using XSLT to do this, or perhaps DOM manipulation, depending on the complexity.

Upvotes: 3

Nuno Linhares
Nuno Linhares

Reputation: 10234

Answered previously here

This might introduce issues that are beyond the scope of Tridion support, so you better be ready to support this yourself.

Upvotes: 3

Related Questions