Camen Design Forum

Using DOMTemplate->repeat() to create complex node structure

append delete jmk

Hi Kroc,

first of all, please receive here my high appreciations for the way made things simpler.
Looking (again) for view templating using the DOM, I found your great article about the matter. After reading it, I downloaded the DOMTemplate and began to make some experiences [...]

I would like to use the repeat functionality to create complex data structure (may be You know how Repeaters works in the wicket Web Framework) .
For example fill a whole table using following template:


<table id="table">
    <th class="hrow">
      <td class="cell"></td>
    <tr class="brow">
     <td class="cell"></td>


(1) select row template (header/body/footer)


$rows = $template->repeat(".hrow|.brow|.frow")


(2) iterate custom data to create rows




Q: how to create cells in different context ?
Using for example


$cells = $template->repeat(".brow, .cell") 


inside my iteration doesn't produce expected results.

I hope You understand my problem.

Best Regards

Reply RSS


append delete #1. Martijn

As far as I know you cannot nest repeaters, so you can’t repeat on both the table rows and table cells. There might be a clever way to get this working, but it is neither documented nor (I think) intended.

In addition, your XPath looks wrong. I think neither the bars in `.hrow|.brow|.frow` nor the commas in `.brow, .cell` are part of XPath?

append delete #2. jmk

Hi Martijn,

thanks for your reply.
I just forgot to mention that the way I wrote command for $rows was just to illustrate the block alternance. BTW, inside <thead> it should be <tr> instead of <th>.

I also tried to build the structure with separate row and cell templates and at least put the results together in a table template. > no success!

append delete #3. Sgt.Nops

Looking for something like this for complex navigation :-(

append delete #4. Chintak



(Leave this as-is, it’s a trap!)

There is no need to “register”, just enter the same name + password of your choice every time.

Pro tip: Use markup to add links, quotes and more.

Your friendly neighbourhood moderators: Kroc, Impressed, Martijn