7

I am trying to render fields of a schema called "Hyperlink" to be Experience Manager friendly.

The schema contains the following fields:

  • Link Text (Type: Text)
  • Internal Link (Type: Component Link)

This allows the editors to specify link text independent of the name of the linked component's name.

The best info I can find on how to render a Component Link for XPM/SiteEdit is here: https://stackoverflow.com/a/13682120/1284894

<!-- TemplateBeginRepeat name="fieldname" -->
  <tcdl:ComponentField name="fieldname" index="${TemplateRepeatIndex}">
    <a href="#" tridion:href="@@Field@@" tridion:type="Component">@@Field@@</a>
  </tcdl:ComponentField>
<!-- TemplateEndRepeat -->

However, I have 2 fields to deal with, not one, where the href part comes from the Component Link field and the link text comes from the Text field. So what should the TCDL markup be in this scenario, or is switching to form editing mode the only way to edit the links with this content modeling approach?

3

Editing two fields means you need to have two different HTML elements that you can edit. So inline with that, you need two TCDL tags too.

The problem you are facing is a common one for which I only found one solution, and that is to add an additional bit of HTML which only shows up when in XPM (since there is no room in your anchor element to allow for editing both the link and the text), see my article on tridiondeveloper.com about having fun with XPM and Page Regions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.