Last active
February 7, 2024 03:32
-
-
Save geekontheroad/ecd8b206041a5a3ebc377efbc05a303c to your computer and use it in GitHub Desktop.
This snippet will add an extra row for each row in the gravity view table. This extra row will have the entry notes in an unordered list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('gravityview/template/table/cells/after', function ($context) { | |
$view = $context->view; | |
$view_id = $view->ID; | |
if ($view_id !== 140) { | |
return; | |
} | |
$fields = $context->fields; | |
$notes = GFAPI::get_notes(array('entry_id' => $context->entry->ID)); | |
// Don't add row if there are no notes for this entry or if error occurred | |
if (empty($notes) || is_wp_error($notes)) { | |
return; | |
} | |
$colspan = $context->fields->by_position('directory_table-columns')->by_visible($context->view)->count(); | |
ob_start(); | |
echo '<ul class="lcs_notes_view">'; | |
foreach ($notes as $note) { | |
echo '<li><strong>' . esc_html(get_note_user($note->user_id)) . '</strong> (' . esc_html($note->date_created) . '): ' . esc_html($note->value) . '</li>'; | |
} | |
echo '</ul>'; | |
$notes_output = ob_get_clean(); | |
echo '</tr><tr class="lcs_notes_tr"><td colspan="' . esc_attr($colspan) . '">Status Notes: <br>' . $notes_output . '</td></tr>'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment