1

When using TemplaVoila, the template data structure is mapped to the HTML template file by pathes like

body[1]/INNER|div.grey[1] div.content_area[1] div.left_column[1] div.left_content[1]

while this is obviously as precise as possible, it is not very effective, because every change to an DOM element above the mapped one would break the mapping, which happens quite frequently and is totally pointless. I like to patch TemplaVoila to rely on the last matching path segments only, which will suffice in almost any condition, as my HTML is always tagged by id's or classes on the mapped elements.

For the start, it would be cool if it would maybe just use

.left_content[1]

instead of the path shown above. But maybe it don't work in a matching fashion like CSS selectors do.

I just can't figure out where to start. Can this be done by TS config? Are changes to TemplaVoila's PHP needed? Can a new extension do this?

dronus
  • 10,774
  • 8
  • 54
  • 80

2 Answers2

0

Add an unique class or even better id to the desired element, so you won't need to count the occurrences. TemplaVoila hasn't possibility to use CSS-like selectors first, last etc.

biesior
  • 55,576
  • 10
  • 125
  • 182
  • That's what I done, all mapped element HAVE unique classes or ids. But TemplaVoila insinst on using the full DOM path of identifyable elements, so the mapping would brake on ANY change in DOM above the mapped one. Which makes the unique naming kinda useless. – dronus Jul 19 '15 at 09:26
  • In the example above, removing the class `grey` for example would break the mapping, despite the mapped element having a unique class itself. – dronus Jul 19 '15 at 09:27
  • 1
    All mapped elements actually would to have an `id` attribute, `class` is not feasable, as I think TemplaVoila maps just the whole path as classes are not unique. If the element has an `id`, it is mapped by the tag name and `id`atrribute only and remaps easily even if moved in DOM. – dronus Jul 23 '15 at 09:41
0

The mapping does not rely on the full path, but tag name and id, if the element mapped has an id attribute set.

Having an (even unique) class attribute only forces TemplaVoila to map the absolute element path, as classes are not necessarily unique.

So no special configuration is needed, if all mapped elements have unique id attributes set.

dronus
  • 10,774
  • 8
  • 54
  • 80