Question

As you probably already know, I'm working hard on some XPM templates with Razor. I've ran into another issue, this time concerning rendering components inside templates in order to make them siteEditable.

The following I'm not sure about. I've got a component which has a title field called "Title", and multivalue componentlink fields which consists of components with a title, description and image. Let's call this one "Linked USP" for now.

Currently this is being rendered by a Template called 'Page Banner', and it just iterates over fields with some If-loops to determine it's presentation, especially for the Title. In order for XPM to work, this template needs to render the component presentation of "Linked USP". So we've created a template called "[XPM] USP ITEM". - this Component template has the 'enable content editing TBB" added to it.

Now the issue arises when I want to make the Title Editable as well. Sounds straightforward, no? Not really - because when the parent template has got a "enable for content editing" TBB added, it will add <span> tags to all editable fields but the templates that gets invoked inside this template will also have <span> -tags, effectively bloating the html and making it impossible to edit the fields inside the RenderComponentPresentation because of duplicate <span>s.

Some code for your fun and to illustrate my issue:

<h1>@RenderComponentField("Title", 0)</h1>

@Foreach(var linkedUSP in Fields.USPS){
     @RenderComponentPresentation("linkedUSP.ID", "tcm:10-1076-32")
}

This template has an enable Content edit TBB added.

now, for the RCP mentioned above, inside its [XPM] template:

<div class="title">@RenderComponentField("Title", 0)</div>
    <p>@RenderComponentField("Description", 0)</p>
    <tcdl:ComponentField name="img">
         <img src="@img" alt="img.MetaData.alt">
    </tcdl:ComponentField>

This one ALSO has the "Enable Content Edit" TBB added. On the front end this happens:

<div class="title"><span><span>Men</span></span></div>

Because the parent template also adds spans to the field.

So my question: how do i solve this? The Title field mentioned above has to be inside the parent template, but I can't create a special template for it becuase it is no component link. I can't get the TBB out of my RCP template, because it won't be editable that way. Interesting huh?

Can't I disable the spans inside template builder somehow?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top