cosmocode/dokuwiki-plugin-struct

Feature request: add class to table header according to field type

Opened this issue · 3 comments

I would like to add classes to table headers according to field type, e.g. dropdown, so I can reference columns when adding features to struct tables.
Could anyone please point me to the location in the code where those classes could be added? Thanks!

AggregationTable::renderColumnHeaders() would be the place

// output XHTML header
$this->renderer->doc .= "<th $width $data>";
$this->renderer->doc .= '<a href="' . $link . '" class="' . $sortclass . '" ' .
'title="' . $this->helper->getLang('sort') . '">' . hsc($header) . '</a>';
$this->renderer->doc .= '</th>';

Thanks Andi for the pointer!

I did this (just for the records):

        // output XHTML header
        $this->renderer->doc .= '<th ';
        if ( is_a($column->getType(), '\dokuwiki\plugin\struct\types\User') ) { 
            $this->renderer->doc .= 'class="struct_user" ';
        }
        $this->renderer->doc .= "$width $data>";

I picked this up again and it workes for me like this, because I need this for struct type user, right now.

However, I would really find this useful for all headers (and all types). But, I don't know, how to do it. 😄

Cheers!

And I replaced the line 367 here https://codesearch.dokuwiki.org/xref/plugin/struct/meta/AggregationTable.php#367 by the following three lines:

$fieldinfo = 'data-field="' . $this->columns[$colnum]->getFullQualifiedLabel() . '"';
$colclass = 'class="col' . $colnum . '"';
$this->renderer->doc .= "<td $colclass $fieldinfo>";

This puts the schema.Title info into each table data cell td.
Now, I can go in CSS, like this:

[data-field="schema.Title"] { display: none; }

... which hides the whole column. Any other CSS rules per column are possible, now.

See here: https://forum.dokuwiki.org/d/22299-feld-vorbelegen-im-seriellen-editor