Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
From #1876964-34: Improve DX when writing style plugins by adding a renderRowGroup() function
//What if I don't want to use theme_views_view_grouping in my style plugin.
$theme_functions = views_theme_functions('views_view_grouping', $this->view, $this->view->display_handler->display);
foreach ($sets as $set) {
$row = reset($set['rows']);
// Render as a grouping set.
if (is_array($row) && isset($row['group'])) {
$output[] = array(
'#theme' => $theme_functions,
'#view' => $this->view,
'#grouping' => $this->options['grouping'][$level],
'#grouping_level' => $level,
'#rows' => $set['rows'],
'#title' => $set['group'],
);
}
Proposed resolution
Replace views_view_grouping
with $this->grouping_theme
.
Or move $theme_functions = views_theme_functions('views_view_grouping', $this->view, $this->view->display_handler->display);
to helper function.
Remaining tasks
Better Title.
Finalize the approach.
Create a patch.
User interface changes
None.
API changes
None
Related Issues
#1876964: Improve DX when writing style plugins by adding a renderRowGroup() function
#1961702: Rename renderSingleGroup to renderRowGroup
Comment | File | Size | Author |
---|---|---|---|
#10 | 1963420-10.patch | 1.34 KB | jibran |
#10 | interdiff.txt | 883 bytes | jibran |
#7 | 1963420-7.patch | 1.37 KB | jibran |
#7 | interdiff.txt | 763 bytes | jibran |
#2 | 1963420-2.patch | 1.37 KB | jibran |
Comments
Comment #1
xjmIf we create new methods, we should
camelCase()
them. (Soon we will activate a big meta to rename all the methods in the codebase that are still under_scores.)Comment #2
jibranThanks @xjm for explaining that.
Here is the patch using
$this->groupingTheme
approach.Comment #3
dawehnerFor sure this patch looks pretty fine
@see should be always after everything else. See http://drupal.org/node/1354
Comment #4
jibranThanks @dawehner for having a look on the patch.
I went through the http://drupal.org/node/1354#see and http://drupal.org/node/1354#var. While creating the patch I copied
It is true for methods but is it true for attributes?
Comment #5
dawehnerNo idea, but I guess it might be better to be consistent.
Comment #6
jhodgdonhttp://drupal.org/node/1354#order gives the order of elements.
Comment #7
jibranThank you @jhodgdon for pointing that out. I should have read it last time but it is damn big page :).
Comment #8
dawehnerThank you.
Comment #9
jhodgdonYes, it is a big page. That is why we now have a nice table of contents at the top so you can find the section you need, hopefully! :)
A couple of notes here:
- You can just refer to @see StylePluginBase::render_grouping_sets() and leave out the namespace, since this is on the same class, if you want.
- I don't think the paragraph of explanation for the @var docs really tells us much that isn't in the first line, but I'm not really against having it there.
- The first line could use a little grammatical cleanup. I suggest:
The theme function used to render the grouping set.
Comment #10
jibranThanks @jhodgdon for the suggestions I have updated the patch accordingly
Comment #11
jhodgdonLooks good to me, thanks!
Comment #12
alexpottCommitted e614787 and pushed to 8.x. Thanks!