Html table // Hide rows

WordPress
17 February, 2022 06:24:02
Topics: 3
Messages: 7
Hi!

My objective is to create a table / list of ACF custom fields to display product data.

I'm trying to create a table 'splitted' on different html objects, in order to dynamically hide some objects (i.e. rows), to avoid getting gap space when some data is empty. In a word: a dynamic table.

I have no problem to hide html objects with IF conditions. However:

1. When I insert my html code in a single html object, the PDF display correctly. But this is not what I need, as the table will show all rows even if some value is empty.
2. When I use several html objects to 'split' my html code, I got "java.util.EmptyStackException" error..

Many thanks in advance for your help !

PS: Amazing plugin, would like to make that work and buy license as we have several templates to implement based on this.

Best,

Stephane
17 February, 2022 07:14:07
E2Pdf
Support
Topics: 7
Messages: 3165
Hi,

It's not working as separate "HTML" objects has different instances. They currently can't be merged and each "HTML" object process separately.

Possible solutions:

1. You can create separate full "HTML" code inside each "HTML" object + use "Actions" to hide/move elements:

<table><tr><td>Title</td><td>Value</td></tr></table>

2. You can try to create preg_replace_filter which will remove all empty rows (Screenshot 1):

#<tr><td>(.*)</td><td></td></tr>#

3. You can try to use "Merge Value" action to merge final value dynamically. (Screenshot 2)

We remain at your service.
We would really appreciate your feedback at WordPress.org!
18 February, 2022 02:55:29
Topics: 3
Messages: 7
HI,

Many thanks for your answers.

Option 3 is working :)

However, Option 2 with preg_replace_filter would be much easier to implement, but I can't make it work. I've used both:

#<tr><td>(.*)</td><td></td></tr># --> all my rows are still displayed, even the empty one
<tr><td>(.*)</td><td></td></tr>. --> nothing is displayed

Any suggestions ?

Thx !
18 February, 2022 03:36:04
E2Pdf
Support
Topics: 7
Messages: 3165
Hi,

Sorry, we just noticed that you have also "b" wrapper tag and new lines.

So if you have exact HTML structure as on first screenshot below preg_replace must work:

#<tr>[\n\r]<td>(.*)</td>[\n\r]<td><b></b></td>[\n\r]</tr>#

We remain at your service.
We would really appreciate your feedback at WordPress.org!
18 February, 2022 03:38:22
Topics: 3
Messages: 7
Awesome !! Working great :) Thx !
5 November, 2023 23:20:30
tyodiwan
Topics: 1
Messages: 4
Hi, I need help with this.
my table like this :
<table style="border-collapse: collapse; width: 100%;">
<tbody>
<tr>
<td style="width: 20%;">FRAME</td>
<td style="width: 3%;">:</td>
<td style="width: 65%;">[e2pdf-wc-product key="frame" meta="true"]</td>
</tr>
<tr>
<td style="width: 20%;">SHELL</td>
<td style="width: 3%;">:</td>
<td style="width: 65%;">[e2pdf-wc-product key="shell" meta="true"]</td>
</tr>
<tr>
<td style="width: 20%;">TOP</td>
<td style="width: 3%;">:</td>
<td style="width: 65%;">[e2pdf-wc-product key="table_top" meta="true"]</td>
</tr>
<tr>
<td style="width: 20%;">CUSHION</td>
<td style="width: 3%;">:</td>
<td style="width: 65%;">[e2pdf-wc-product key="cushion" meta="true"]</td>
</tr>
<tr>
<td style="width: 20%;">PADDED CUSHION</td>
<td style="width: 3%;">:</td>
<td style="width: 65%;">[e2pdf-wc-product key="pad_cushion" meta="true"]</td>
</tr>
<tr><td style="width: 20%;">UPHOLSTERY</td>
<td style="width: 3%;">:</td>
<td style="width: 65%;">[e2pdf-wc-product key="upholstery" meta="true"]</td>
</tr>
<tr><td style="width: 20%;">SLING</td>
<td style="width: 3%;">:</td>
<td style="width: 65%;">[e2pdf-wc-product key="sling" meta="true"]</td>
</tr>
<tr><td style="width: 20%;">PADDED SLING</td>
<td style="width: 3%;">:</td>
<td style="width: 65%;">[e2pdf-wc-product key="padded_sling" meta="true"]</td>
</tr>
<tr><td style="width: 20%;">CURTAIN</td>
<td style="width: 3%;">:</td>
<td style="width: 65%;">[e2pdf-wc-product key="curtain" meta="true"]</td>
</tr>
<tr><td style="width: 20%;">SHADE</td>
<td style="width: 3%;">:</td>
<td style="width: 65%;">[e2pdf-wc-product key="shade" meta="true"]</td>
</tr>
</tbody>
</table>

I can't find merge on htlm actions
thank you.
6 November, 2023 01:20:31
E2Pdf
Support
Topics: 7
Messages: 3165
Hello,

Do you need to add content to the "HTML" object dynamically? If so, the "merge" functionality was changed, see please the documentation here: https://e2pdf.com/docs/elements/html/dynamic-content#dynamic-merge
We would really appreciate your feedback at WordPress.org!
6 November, 2023 01:55:12
tyodiwan
Topics: 1
Messages: 4
Ah I found it, thank you... let me try...