Skip to content

Instantly share code, notes, and snippets.

@rafaehlers
Last active March 4, 2022 20:44
Show Gist options
  • Save rafaehlers/243b757de60f79241987a9d8239c0111 to your computer and use it in GitHub Desktop.
Save rafaehlers/243b757de60f79241987a9d8239c0111 to your computer and use it in GitHub Desktop.
Highlight an entire row if field condition is met (only works with Table View)
<?php // DO NOT COPY THIS LINE
add_filter( 'gravityview/template/table/entry/class', function( $class, $context ) {
$view_id = $context->view->ID;
if($view_id == 46){ // Modify to target only View with specific ID (46 in this case)
if ( $context->entry[1] == '1' ) {
$class .= ' highlight-yes'; // If field ID 1's value is equal to 1 then add the CSS class
}elseif( $context->entry[1] == '0' ){
$class .= ' highlight-no'; // If field ID 1's value is equal to 0 then add the CSS class
}elseif( $context->entry[1] == '2' ){
$class .= ' highlight-maybe'; // If field ID 1's value is equal to 2 then add the CSS class
}
}
return $class;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment