Zum Hauptinhalt gehen

Get content as simple text from DOMTABLE like getting table within DOM with toText

Kommentare

3 Kommentare

  • Zendesk API User
    Author: hoebbel - 4/8/2025 13:28

    Hello Connz,

    I would try the table function. You can use it to output tables as required. This will get rid of the table, tr and td format templates.
    If format templates are also used within the table cells, it becomes more difficult if their output has not been configured accordingly for the text output channel anyway...

    Instead of using the table function, you can also modify the corresponding format templates (table, tr, td). However, this doesn't solve the problem of the format templates used within the cell contents.

    Best regards
    Holger

    0
  • Zendesk API User
    Author: cpe - 4/10/2025 10:53

    Hey Holger,

    I have custom format templates (table, tr, td) anyway and there are only a few other format templates used, so I think adjusting the output there would be the most fitting.

    I tried that first, but run into this strange issue:

    If I leave the initial $CMS_VALUE(#content)$ in all format templates, I get the output I want directly. The problem is, that I am going through all content and collection all texts in a variable to insert into JSON at the end. So I would need something like:

    $CMS_SET(void, set_description.add(#content))$

    I put that in the td and it results in "de.espirit.firstspirit.generate.ElementRenderer$ChildPrinter@..." for every cell in the set_description.

    I then tried saving the output in a set variable and using that:

    $CMS_SET(set_content)$ $CMS_VALUE(#content)$ $CMS_END_SET$ $CMS_SET(void, set_description.add(set_content))$

    When I output set_content with CMS_VALUE is it set correctly, but I get "\n\t$CMS_VALUE(#content)$\n" in my set_description.

    In the table function I also have to handle #content, so I think that would result in the same issues?

    I think I am on the wrong element here because of the other Format Templates like p/li/u/i/etc. But they can be nested within each other, so I would not know where to put the set_description and where just output #content.

    Do you have another hint for me?

    Cheers
    Connz

    0
  • Zendesk API User
    Author: cpe - 4/10/2025 12:05

    PS:

    Ich habe eine Lösung, aber sie ist... sieh selber:

    Ich habe in dem Template, in dem ich das DOMTABLE habe, ein hidden DOM hinzugefügt und dann klappt das hier:

    $CMS_SET(void, st_hidden_dom_for_json.set(st_table.getDom()))$ $CMS_SET(void, set_description.add(st_hidden_dom_for_json.toText(false).trim()))$

    Wenn jemand noch eine andere Lösung hat, die sich besser anfühlt, dann gerne her damit!

    1

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.