Within the author it displays a breadcrumb, and I know you can modify its display to either some other static text or localisation, but I'm wondering if it's possible to dynamically show an attribute, or execute some other context-specific xpath dynamically.
As a test I can change the breadcrumb using the localisation editor variable ${i18n()}
.
cc_config.xml
<elementRenderings platform="webapp">
<render element="num" as="${i18n(test)}" annotation="${i18n(test)}"/>
translation-cc.xml
<key value="test">
<comment></comment>
<val lang="en_US">Year</val>
"Year" is actually a num
element.
However, trying any other variable, even 'more static' ones like ${cf}
or ${tp}
simply render the variable text literally, instead of evaluating it.
cc_config.xml
<elementRenderings platform="webapp">
<render element="paragraph" as="${xpath_eval(./@eId)}" annotation="${xpath_eval(./@eId)}"/>
<render element="p" as="${tp}" annotation="${tp}"/>
(paragraphs do have an eId
attribute)
As you can see, I tried using annotation
; but these tooltips also simply display the variable literally.
I also fiddled and tried a bunch of xpath stuff, like @eId
/.@eId
//@eId
, but I think there's some restriction in using the Content Completion Configuration File with respect to editor variables.
So is the thinking right but I am doing something wrong, or is it not the right way but there is some other way to affect the breadcrumb? Maybe with the schema?
The element display names in cc_config.xml
file do not support most of the editor variables. Most of them, like ${cf}
(current file) and ${tp}
(total number of pages) don't make sense to be used when rendering the name of an element.
The xpath_eval
would make sense - the display name of an element may depend on its attributes (e.g. the @id
attribute), it's index in the document (e.g. 'Section 3'), etc. We have a feature request registered for this case and I added your vote to it.
As a partial workaround you can use a JS API to compute the display name of the element based on the element original name and its attributes:
goog.events.listen(workspace, sync.api.Workspace.EventType.BEFORE_EDITOR_LOADED, function(e) {
e.options.elementNameEnhancer = function(elemName, attrs) {
var displayString = elemName;
var attr = attrs['id'];
if (attr) {
displayString += ' (#' + attr.attributeValue + ')';
}
return displayString;
};
});