There is no option to group content of two or more rows by tab field.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

vslklv created an issue. See original summary.

vslklv’s picture

Created checkbox if you want to group content by tab field.

vslklv’s picture

Status: Active » Needs review
universalhandle’s picture

I needed this for a Drupal 7 site. A patch based off of @vslklv's work is attached. It works great if you need to group results once.

Unfortunately, this doesn't really go far enough for my needs. In my case, I'm building a schedule for an event. If I set the tab field to my "day of week" field and check the new "Group by tab field" box, I get the expected tabs for Monday, Tuesday, etc. However, there's no way to group beneath that (e.g., by time of day or topic). When I select my "time of day" field for grouping, the grouping occurs before my "day of week" tab field. So, whereas I'm looking for something like:

+ Monday
++ 9 am
+++ Item 1
+++ Item 2
++ 12 pm
+++ Item 3
+++ Item 4
+ Tuesday
++ 9 am
+++ Item 5
+++ Item 6

... I end up with something like:

+ 9 am
++ Monday
+++ Item 1
+++ Item 2
++ Tuesday
+++ Item 5
+++ Item 6
+ 12 pm
++ Monday
+++ Item 3
+++ Item 4

... and to boot the display is a mess.

I think this approach is ultimately wrongheaded, but since I did the work to backport it and someone else might find it useful, I thought I'd share.

I tried an alternate approach where I overrode views_plugin_style->render_grouping_sets() in ViewsBootstrapTabPluginStyle (with one difference being that rather than using an explicit setting like @vslklv did, my code looks for the tab field and the first grouping field to have the same value), but I'm not sure that's the right place to intercept Views's default behavior either. Ultimately I gave up trying to do this in a generic way and hardcoded some implementation-specific details in an implementation of template_preprocess_views_bootstrap_tab_plugin_style.

catherineahayes’s picture

This was super helpful for me, GinkgoFJG. Thanks! One possible improvement. I was getting "undefined offset" messages at line 32, so changed to this instead and they went away:

if(array_key_exists($new_row_key, $vars['rows'])){
  $vars['rows'][$new_row_key] = array();
 }
paulsheldrake’s picture

Hello

The patch in #2 had an issue with the removal of the orginal grouping if statement that hid the setting form. I have re-rolled the patch to fix the settings form.

paulsheldrake’s picture

Sorry, didn't export all the changes in the last patch. This one should be good.

paulsheldrake’s picture

StatusFileSize
new5.26 KB

Update patch for fix on tab labels from here https://www.drupal.org/project/views_bootstrap/issues/2997294

gabriel.nunez’s picture

Any updates on this? I applied the last patch and it stills shows a tab per element in the view, showing duplicates in my case. The "Group by tab field" option is checked.

chris matthews’s picture

Assigned: vslklv » Unassigned
chris matthews’s picture

Version: 8.x-3.0 » 8.x-3.x-dev
Status: Needs review » Needs work
shelane’s picture

Assigned: Unassigned » shelane

  • shelane committed a063e7f on 8.x-3.x
    Issue #2948150: Views Bootstrap Tabs cannot be grouped
    
shelane’s picture

Status: Needs work » Fixed
Nikitoring’s picture

You fixed, but in develop version in ViewsBootstrapTab.php file last close bracket is is error

shelane’s picture

@Nikitoring I'm not sure what you mean that the last close bracket is in error. The close bracket on line 99 closes the buildOptionsForm function and the close bracket on 101 closes the ViewsBootstrapTab class.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

d.sibaud’s picture

Can't find the expeted code in the a063e7f commit,
I here with attach a patch done against the current dev version.

shelane’s picture

StatusFileSize
new91.12 KB
new34.78 KB

@tourtools. I'm not sure what you are trying to do in the patch. I am using the Views grouping that is built-in which your patch turns off. That grouping allows you to select a field to group by and handles the work of creating the rows. You have also removed improvements I made to the template with the patch.

Grouping does work in the current version:

Settings for Tabs

Output for tabs

See the documentation for Tabs.

d.sibaud’s picture

StatusFileSize
new449.37 KB

Hello @shelane,
I'm trying to add what was done by @vslklv, @universalhandle and @paulsheldrake in their patches:

in other words, using the views' grouping behavior to group contents with the same grouping field value in the same tab.

Is less useful grouping several tabs with one content per tab under the same grouping field value than to have several nodes with the same grouping field value all under the same tab (see screenshot).

shelane’s picture

While that does seem like a nice feature:

1) Create a new issue and not remark on one marked as fixed.

2) I do not plan to take away the views based grouping option. Any other features will have to be in addition to that.

3) Be aware of what you are trying to change in the template as what was in the patch was destructive.

d.sibaud’s picture

1) the issue was marked as fixed but the commit done doesn't answer to the true feature request underlying the title: the one expressed by the reporter and the following developer who tried to improve his first patch

2) absolutely agree, better to add the availability to choose between keeping the views standard grouping behavior and the one requested with this feature request issue overriding the first only if the "Group by tab field" is checked

3) I'll try my best in the future to avoid changing what already done good, thanks

shelane’s picture

Status: Closed (fixed) » Active

1) point taken

I am reopening this to continue investigating this issue.

shelane’s picture

Issue summary: View changes
shelane’s picture

Status: Active » Closed (works as designed)
Related issues: +#2688789: Group as tabs doesn't work

After evaluating the proposed code changes, I’ve decided that the approach can have some very strange outcomes if there is any pager in place. I’d rather continue to use the default views grouping (which also has its purpose) than trying to do some loop and catch of the row data. I thought I had seen this discussed before and I did. The issue for the 7.x version is now linked. I understand what you want to do here, but I think you can accomplish this by adding the Views Field View module.

ey’s picture

Version: 8.x-3.x-dev » 8.x-4.x-dev

I'm reopening this issue, because it is still not working for the 8.x-4.x. There's no option for grouping.

ey’s picture

Status: Closed (works as designed) » Needs work
ericmaster’s picture

Re-rolled the patch in #8 against 8.x-4.x.

yassersamman’s picture

Just fix the wrong brackets in the last re-roll against 8.x-4.x, and a minor fix for t function.
Although I still don't know why we need to unset($form['grouping'])
It seems unnecessary.

anas_maw’s picture

Fixed active state and added fade effect

anas_maw’s picture

Status: Needs work » Needs review

The last submitted patch, 28: views-rows-content-grouped-by-tab-field-2948150-28.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

The last submitted patch, 29: views-rows-content-grouped-by-tab-field-2948150-29.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 30: views-rows-content-grouped-by-tab-field-2948150-30.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

shelane’s picture

Assigned: shelane » Unassigned

Unassigning myself since this is now assigned to the 4.x branch.

steveoriol’s picture

Re-rolled the patch for 8.x-3.x.

steveoriol’s picture

Changed tab grouping pattern to work when tabs are generated with "Global: Custom text" and other fields...

webdrips’s picture

Re-roll of #30 against the latest 8.-4.-dev branch

webdrips’s picture

webdrips’s picture

Let's try this again: re-roll of #30 against the latest 8.-4.-dev branch

shelane’s picture

Version: 8.x-4.x-dev » 5.4.x-dev
suresh prabhu parkala’s picture

StatusFileSize
new7.59 KB

Re-rolled patch from #40 against latest 5.4.x-dev. Please review.

ronraney’s picture

Is anyone working on a patch for the alpha release? I tried the patch and it didn't work. I did get it working with custom code. I don't trust myself to create a patch because I don't have git working. I basically modified the same files where applicable.

ronraney’s picture

I think options for sorting the tabs using the Tab form would be a good addition. Options for sorting could be provided programmatically but it's beyond my capacity to contribute at this time. Even if it were only alphabetical, that would be helpful to me.

Pawel Bozyk’s picture

StatusFileSize
new7.81 KB

Hi, the patch from comment #42 doesn't work with views_bootstrap 5.5.x, so I'm uploading a new one. Created and tested for Drupal 9.5.2

Pawel Bozyk’s picture

Version: 5.4.x-dev » 5.5.0-alpha1
Status: Needs work » Fixed
shelane’s picture

Status: Fixed » Reviewed & tested by the community

An issue is not considered fixed until code has been committed and the project maintainer has marked it as fixed. I'm setting this back as RTBC for now until I get a moment to test and commit code.

ammar qala’s picture

Hi, the patch from comment #45 doesn't work with views_bootstrap 5.5.0-alpha1, so I'm uploading a new one. Created and tested for Drupal 10.2.3

ammar qala’s picture

when the tab is <a></a> tag it doesn't work on views_bootstrap 5.5.0-alpha1
switching from a tag to button.

  • shelane committed 4c6057e3 on 5.5.x
    Issue #2948150 by paulsheldrake, shelane, webdrips, Ammar Qala,...
shelane’s picture

Status: Reviewed & tested by the community » Fixed
shelane’s picture

FYI, I am currently doing a deeper dive on tabs and this particular implementation will not be the final.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.