Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we replace the <add text> labels in SiteEdit 2012 (on Tridion 2011)?

Right now I've been implementing User Interface 2012 and after some hurdles it works just fine. I've been looking to optimise the usability of any UI-editable fields, and run into a related challenge.

Within a component there are several fields that are not mandatory, and as such should not be displayed when they are empty. As soon as an editor enters UI and selects the component holding said fields, several labels such as <add text> and <add internal link to component media> appear.

I am looking to change these labels to something more descriptive of their content, because additional html will be added to the page when a field is not empty.

For example (using Razor Mediator):

@if(Component.Fields.location != null) {
  <span class="row">
    <strong>Where:</strong>
    <span>@RenderComponentField("location", 0)</span>
  </span>
} else {
  <tcdl:ComponentField name="location"></tcdl:ComponentField>
}

When the location field is empty, it just says <add text>. I would like to change that to <Add location to event>.

I've tried putting something between the tcdl-tags, but they display even when not editing in UI2012. I've been searching the SDL Live content sites but I cannot find any reference to it. Anyone have an idea?

like image 626
MDa Avatar asked Jun 22 '12 08:06

MDa


3 Answers

There is no supported way for customizing placeholder text of the empty field. But you could try to write an extension, which overrides the following method:

Tridion.Web.UI.SiteEdit.ComponentField.prototype.setPlaceholderType

This method is responsible for setting up the placeholder text.

like image 75
Boris Ponomarenko Avatar answered Oct 25 '22 17:10

Boris Ponomarenko


I was looking for the same when I was checking this, but I don't think that is doable easily AFAIK. I went little bit deep and found that the labels are part of resource file Tridion.Web.UI.Editors.SiteEdit.Strings.resx EmptyTextField. I did not pursue the option to fiddle with this because it would not be the supported way, nor documented and on top of it I still don't have the flexibility of adding my own text for the each field.

Back to your question, I was tossing up an idea (not necessarily answer to your question) and want to share here so the experts could provide some valuable suggestions. I did not try this option (i felt too much work) and this is in my long todo list and might have some drawbacks as well.

  • Create Schema Fields with "default values" (e.g; "Add location to event"). the default text will be displayed in your UI.

  • Write Your templates in a way that if the Schema field value is same as default

@@if(Component.Fields.location.value == [Compare the schema field definition - default value of the field]) { 
    //--> Note: I could not find a straight API for this.. but I am assuming it should be there.
    @RenderComponentField("location", 0)
} else {
    <span class="row">
        <strong>Where:</strong>
        <span>@RenderComponentField("location", 0)</span>
    </span>
}
  • Perform above condition check based on target type UI enabled, since we do not want to display the default text for live target etc.

Also, posting Tridion Idea as enhancement request will be great. I will do it in next few days if none exist already.

like image 27
Ram G Avatar answered Oct 25 '22 17:10

Ram G


I like the approach as it'd be a quick way to give author's instructions at the field level. We use the description field to typically provide this type of help in the CME.

For inline editing, content types (SDL Live Content - login required) is another option since they define schema (and prototype component), template, instructions, and "save-to" context. You can offer dummy text that authors replace.

Tips:

  • Add sample content and/or instructions (Lorem Ipsum) in the prototype component.
  • Add additional instructions in the content type description.
  • Select storage location other than the prototype component's folder.

Let us know how it goes. :-)

like image 41
Alvin Reyes Avatar answered Oct 25 '22 18:10

Alvin Reyes