Skip Navigation

[Resuelto] conditionally remove html table headings

This support ticket is created hace 6 años, 10 meses. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Etiquetado: 

This topic contains 9 respuestas, has 2 mensajes.

Last updated by christerA hace 6 años, 10 meses.

Assisted by: Minesh.

Autor
Mensajes
#520489

Hi.
I have a View which display things with a html table.
In the content template i have a condition for date, like:
[wpv-conditional if="( $(wpcf-thedate) gte 'TODAY()' )"]

If no entries have a date after today i want NOTHING to show.
But how do i remove the table headings?

#520518

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

What are you displaying inside the conditional shortcode? Could you please share code you added to loop output section of your view?

#520541

Hi.

This is in the "Loop item in show Town and Date":

[wpv-conditional if="( $(wpcf-coursedate) gte 'TODAY()' )"]
<td>[types field='coursedate'][/types][types field='remote'][/types]</td>
<td>[types field='courselength'][/types]</td>
[/wpv-conditional]

-----------------------------------------------------------

And this is in the "Loop Output Editor":
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<table width="100%">
<thead>
<tr>
<th style="font-size: 14px; font-weight: normal;">Course start</th>
<th style="font-size: 14px; font-weight: normal;">Length</th>
</tr>
</thead>
<tbody class="wpv-loop js-wpv-loop">
<wpv-loop>
<tr>
[wpv-post-body view_template="Loop item in Show Town and Date"]
</tr>
</wpv-loop>
</tbody>
</table>
<!-- wpv-loop-end -->

[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"][/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]
------------------------------------------------------------------
I don't want "Course start" and "Length" table heading to show at all when no items have dates in the future.

#520547

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - you should add the class "mytable" to your table tag -
For example:

<table width="100%" class="mytable">

Then please try to add following code to your view's output editor JS box:

jQuery(document).ready(function($){
if ($(".mytable tr:has(td)").length == 0) {
    $(".mytable").hide();
}
});

Now - save your view and check on the frontend and hopefully, you will get your desired results.

#520566

Hi.

You mean the JS box in the "Loop Output Editor"?
I did that, but it's still showing.
Does this realy work?
if ($(".mytable tr:has(td)").length == 0)

I mean, is the table really empty? There ARE items in it, but with the date older than today?

I actually have another thing i want to hide, see below code, it's the line with the h5 tags.

[wpv-layout-start]
[wpv-items-found]
<h5>[get-the-city city="[wpv-attribute name="city"]"]</h5>
<!-- wpv-loop-start -->
<table width="100%" class="mytable">
<thead>
..... the rest...

#520572

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - $(".mytable tr:has(td)").length will check for tag td inside the TR tag.

Is it possible for you to share temporary access details so that I can quickly fix this for you.

Please share problem URL where you added your view.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#520597

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

Wrap h1 tag with the div. As you can see with following example I wrap h1 using div with class myh1.

For example:

[wpv-layout-start]
[wpv-items-found]
<div class="myh1">
<h5>[get-the-city city="[wpv-attribute name="city"]"]</h5>
</div>
<!-- wpv-loop-start -->
<table width="100%" class="mytable">

Add this code to your loop output sections JS box:

jQuery(document).ready(function($){
if ($(".mytable tr:has(td)").length == 0) {
    $(".mytable").hide();
    $(".myh1").hide();

}
});

This should hide both h1 and table with table do not have any td.

#520662

Hi.

Both are still showing.
I've tried with different browsers, cleared cashe, etc.

Have you replicated it in your own test site?
Does it work there?

#520668

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - I've tested and you can see it working here:
=> hidden link

As you can see there is no <td> tag available so its not displaying any content.

Now - add following between before table tag end and click on update and then click on run:

<tr><td>some title</td></tr>

You will see the result as <Td> tag is available in the table.

To fix this quickly I recommend that you should setup a test site and share access details with me.

#520672

Hi.

Let's take a weekend break, i'll continue next week why it's not working on my site.
But the code you sent looks good, i'll keep testing.
We can close this ticket for now.
Thank you for all you help.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.