backdrop / backdrop-issues

Issue tracker for Backdrop core.
144 stars 40 forks source link

Improve code comments for template_preprocess_views_view_fields #6722

Open dsearle-oaklins opened 1 month ago

dsearle-oaklins commented 1 month ago

Description of the need

I was frustrated and lost time while trying to set the value of some custom fields in my view. In part that happened because I assumed that the hook template_preprocess_views_view_fields would process for all fields in any view. It was firing for some views I had, but not the one I was working on. This turned out to be because the view was using the Table format, so I should have used the template_preprocess_views_view_table hook.

Proposed solution

Just add some more info in the code comments of the template_preprocess_views_view_fields hook, to give some clues about what's happening.

indigoxela commented 1 month ago

add some more info in the code comments of the template_preprocess_views_view_fields hook

So what's missing in docs is to mention where ..._fields and ..._table actually apply - am I getting this right? I'm the first to admit, that the doc block of that function is sparse. Very sparse. A lot of room for improvements. At least we should add @see views-view-field.tpl.php.

@dsearle-oaklins what would be your suggestion? Especially the wording.

Looking at views.theme.inc with its various template_preprocess_views_view* functions - none of those provides any clue. High time to fix that.

dsearle-oaklins commented 1 month ago

I was going to to the PR myself but got stuck trying to connect git to a different user to do that how I wanted it to be, so, in lieu of that, this is what I had added to the comment:

/**
 * Preprocess theme function to print a single record from a row, with fields.
 * This hook will only be run on views whose Format settings choose to show fields.
 * Therefore, it won't run for views that use the Table format.
 */
function template_preprocess_views_view_fields(&$variables) {

Just that, to cover my initial point of confusion.

Do these code comments end up on the website documentation too?

dsearle-oaklins commented 1 month ago

I figured it out and there's a PR for you.

avpaderno commented 1 month ago

I left a comment in the MR.