Search the FirstSpirit Knowledge Base
Yesterday I had to template an inline table with thead and tbody.
So I checked the documentation if there ist something like #table.firstRow ist available or #table.rowNumber or something like that.
#table.lastRow is available.
I coded a counter to check for the table head, so this problem is solved for now.
But is it possible to extend the systemobject #table by the data field rowNumber or firstRow or something like that?
The system object #cell has (among others) the boolean properties firstRow and lastRow.
I think extending #table would not server your need (#table.lastRow delivers the index of the last row).
That's right. But when I am in the depth of #cell I have no #row.
So I have to code something like
into my #cell and I think that is not an recommendable / handy way.
Ok, so you ar missing a #row system object. This name is already used for the rows of content selects.
In the format template for 'Table Row' you can use #global.context instead - e.g. #global.context.firstRow (boolean).
But you must still use an $CMS_IF(..)$ in the format template 'Table Cell' to distinguish between the tags th and td.
Sorry for the mistake to #row.
Ok so far. Thanks for the information.
I solved that problem with a counter. My counter counts the rows, so i can check in which row I am.
Here is my code. I hope you understand my problem better then:
$CMS_IF(counter == 0 && st_table_head)$
$CMS_IF(counter == 0 || st_table_head && counter == 1)$
I could replace the "counter == 0" by #global.context.firstRow, but I still need the counter for "counter == 1" to check for the tbody in case of using thead.
Or is there a #global.context.secondRow? I can't imagine that.
rbitdd wrote: Or is there a #global.context.secondRow? I can't imagine that. You could use #global.context.row == 1.$CMS_IF(#table.lastRow)$ </tbody>$CMS_END_IF$Cannot imagine that this code is working, #table.lastRow is a numeric value, not a boolean.
You could use #global.context.row == 1.
$CMS_IF(#table.lastRow)$ </tbody>$CMS_END_IF$Cannot imagine that this code is working, #table.lastRow is a numeric value, not a boolean.
Cannot imagine that this code is working, #table.lastRow is a numeric value, not a boolean.
This is exactly what I was looking for. In a different context, but exactly what I was looking for.
You were right the part with #table.lastRow didn't work haven't seen that before. thanks for the hint.
Now my code looks like this (without counter )
$CMS_IF(#global.context.firstRow && st_table_head)$
$CMS_IF(#global.context.firstRow || st_table_head && #global.context.row == 1)$
$CMS_IF(#table.lastRow == #global.context.row)$
So, the remaining feature request is a short cut #row for the table row render context !?!
That would be nice!
With properties like: lastRow, firstRow as boolean and currentRow as integer.
Perhaps the name should be better #tableRow or #trow or something like this. To distinguish it from the content rendering variable name...
This internal id for this feature is #94459.
The context name will be #tr.
Current row number will be available with #tr.row, #tr.lastRow, and #tr.firstRow will both deliver a boolean.
The feature is scheduled for version 4.2.R4.