Skip Navigation

[Resolved] Hiding a complete div if all conditionals are met

This thread is resolved. Here is a description of the problem and solution.

Problem:
Hiding a complete div if all conditionals are met within Layout row

Solution:
You can use the Layouts filter hook "ddl_render_row_start" to conditionally display the row.

You can find the proposed solution in this case with the following reply:
=> https://toolset.com/forums/topic/hiding-a-complete-div-if-all-conditionals-are-met/#post-1778477

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/layouts-framework-api/

This support ticket is created 4 years, 2 months ago. 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.

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)

This topic contains 3 replies, has 2 voices.

Last updated by chrisC-25 4 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1776101

I have a layout that I want to use for a custom post type. However some of the posts have a special section that requires a colored background. I have setup conditionals to not show all the custom fields in the div if they are empty. But, the colored background still shows as an empty box. How can I hide that colored box if all the fields in it are empty?

Example of post with populated fields:
hidden link
Example without the populated fields:
hidden link

Thanks

#1776923

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

As I understand - you are using the Toolset Layout plugin and you want to hide the Layout row/Cell conditionally based on the custom field value. If this is correct.

There is no such feature available with Layouts to control the Layout row/cell display conditionally based on the custom field value.

However - there could be couple of workaround using CSS or JS we can add to achieve your goal.

If you can share access details, I would be happy to check and apply the workaround.

*** 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 have set the next reply to private which means only you and I have access to it.

#1778477

Minesh
Supporter

Languages: English (English )

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

Can you please check now: hidden link

I've added the following layout filter to the "Custom Code" section offered by Toolset:
=> hidden link

add_filter( 'ddl_render_row_start', function( $markup, $args, $row, $renderer ){
 global $post;
  
$is_empty = false;
  
if($args['additionalCssClasses']=='pop-culture-box') {
  	 $value = get_post_meta($post->ID,'wpcf-pop-culture-text',true);
     if(empty($value)){
       	$is_empty = true;
     }
}
  
        if( $is_empty ){
            ob_start();?>
               <<?php echo $args['tag']; ?> class="hidden"<?php if ($args['cssId']) { echo ' id="' . $args['cssId'] . '"'; } ?>          
            <?php
        $markup = ob_get_clean();
        }
 
        return $markup;
}, 99, 4 );

More info:
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

I can see now the class if there is no value available for the field "pop-culture-text" it does not display any box with background colour.

#1779087

My issue is resolved now. Thank you!