The quicktabs style is hard coded to Commons pills. Is there some way to affect this? Also there are cases where I want to not display certain commons content types in the filter based on site or group role. I can do this for my custom content types, but not for commons content types.
Could we add an alter so the $settings and $tabs can be altered:
function commons_bw_generate_group_widget($group = NULL) {
....
// allow altering $settings and $tabs
drupal_alter('commons_bw_generate_group_widget', $settings, $tabs);
// Generate the Quicktabs instance.
return quicktabs_build_quicktabs('commons_bw', $settings, $tabs);
}
I have attached a patch, but not sure it is set up correctly for commons_bw.
Comments
Comment #1
RobKoberg commentedPatch attached
Comment #2
ezra-g commentedIs there a reason hook_quicktabs_alter() or hook_commons_bw_[widget_type]_alter aren't sufficient?
If so, please feel free to re-open with an explanation of why a new hook is necessary.
Comment #3
RobKoberg commentedI am just seeing hook_quicktabs_alter now. And I did not see hook_commons_bw_[widget_type]_alter. Thanks, I will try those.
Comment #4
RobKoberg commentedActually, hook_quicktabs_alter does not work. This comes backas false so the drupal_alter is never called:
Perhaps the quicktabs style plugin needs to provide info/register for quicktabs?
It would also be nice to be able to affect all tabs that have been collected in one function rather than catching each type with hook_commons_bw_[widget_type]_alter.
What do you think?
Comment #5
RobKoberg commentedIt seems like the problem is in quicktabs. The quicktabs_load function calls quicktabs_load_multiple, but it returns an empty array:
/**
* Load the quicktabs data.
*/
function quicktabs_load_multiple($names = array()) {
ctools_include('export');
$defaults = empty($names) ? ctools_export_load_object('quicktabs', 'all') : ctools_export_load_object('quicktabs', 'names', $names);
dpm($defaults, '$defaults');
return $defaults;
}
ctools_export_load_object is looking in the quicktabs table, but quicktabs table is empty. I went to /admin/structure/quicktabs/styles and set it to Commons Pills, saved, but the quicktabs table was still empty. Any ideas?
One thing that is different about my implementation of commons is I am not using commons_origins or a subtheme of adaptivetheme (using a custom twitter bootstrap theme).
Comment #6
RobKoberg commentedOK, to get the hook_quicktabs_alter to work, you need to go to: /admin/structure/quicktabs and add a new Quicktabs instance. It must have the machine name commons_bw and then the alter will work.
HOWEVER, you need to define tabs when you Add Quicktabs Instance which kind of screws up the browsing widget. So I think this should be reopened as the easiest way to allow changing the quicktabs would be to put in the alter as my OP suggests.
Comment #7
RobKoberg commentedMore on this, even if you set up the quicktabs instance, only the tabs setup in the instance will show up for the alter. The ones set up in the commons_bw_generate_group_widget will not appear. There is no way to set the group argument for the view in the quicktabs tab builder interface. So the only things that would be altered is to remove the tab created by the quicktabs instance GUI and change the style.
This is not optimal. (see attached screengrab)
I am using Font Awesome icons ( http://fortawesome.github.io/Font-Awesome/icons/ ), so I want to affect those for the tabs somehow...
Comment #8
RobKoberg commentedI am changing this to a bug report because you cannot modify the quicktabs. I am attaching a patch based of todays (10 minutes ago) git repo.
Can you please put in the alter. It is a simple one line fix, has no repercussions and will provide users the only way to alter the quicktabs,
Comment #9
behoppe333 commentedThanks for this fix.
Newbie question: If I apply this patch, where would I then go to alter the quicktabs? Will something show up in admin > structure > quicktabs for me to edit?
Comment #10
RobKoberg commented"If I apply this patch, where would I then go to alter the quicktabs? Will something show up in admin > structure > quicktabs for me to edit?"
No, it would need to be done in code. I define a quicktabs style in the alter and remove certain tabs that certain users should not see:
I also duplicate the CTools plugin for the bw_group widget, e.g some_module/plugins/content_types/my_bw_group:
Comment #11
RobKoberg commentedAs this is getting closer to release changing priority to critical, there needs to be a way to alter the quicktabs. As explained above there is no ways to do this now. I am not using the commons theme and need to setup the HTML structure of the quicktabs (for twitter bootstrap). Can this get done please?
Comment #12
ezra-g commentedIt sounds like the motivation for this patch is the same as this issue in QuickTabs: #1795982: Allow for hook_alter for instances coming from code.
@RobKoberg: Are you able to review that patch and see if it addresses your issue? Doing so would help get it committed to QuickTabs as a long term solution, and included in the Commons make file as a short term solution.
Comment #13
RobKoberg commentedI have not had a chance to test this yet. The ticket does seem to address the problem, but the first and last time the issue was touched was in Sept 2012. In other words, not much activity on the issue. Putting the one-line alter in commons_bw does solve it without needing to patch another module. The alter could potentially expose other things specific to commons_bw, so it would be great to get this in. I am curious why the resistance? I am going to doing a dev build today, so can test out the latest changes. I am still working out how to use features effectively and still integrate with the latest changes that come down. I can't say it is working well.
In addition to features, might the configuration module help us all: https://drupal.org/project/configuration
...
My use case is that there are two types of users (among others): Teachers and Students. Teachers can see more content types than the student. The student should not see the content types that only teachers should see (one in commons is the Document content type).
I also use twitter bootstrap for my theming and need a specific structure for my version of their navbar http://twitter.github.io/bootstrap/components.html#navbar
Comment #14
ezra-g commentedThe goal here is to get the proposed patch committed to the QuickTabs module so that a patch is no longer required and so that maintenance of the code can be shared across the QuickTabs & Commons maintainers, as well as potentially the 55,000+ sites running QuickTabs . This can only happen when people review the patch. The referenced issue has no reviews, which is the reason why it hasn't been committed to QuickTabs. Imagine if everyone avoided reviewing issues that didn't have activity: It would be a self-fulfilling cycle and issues wouldn't get reviewed.
So, encourage you to review the upstream patch so that it can get committed. Feel free to reach me in #drupal-commons on IRC on freenode.net if you'd like to discuss further.
Comment #15
RobKoberg commentedOK, I applied the patch from #1795982: Allow for hook_alter for instances coming from code. It applies cleanly, but does not really do anything. The relevant quicktabs code is in the .module file:
No $info is found in
if ($info = quicktabs_load($name)) {so it goes to theelseif (!empty($custom_tabs)) {That will trigger the alter, but there is no $info to alter. And it does not send the $tabs along for me to filter based on user permissions and/or group role.
So, no, it does not provide any help.
I have attached a new patch. In this latest one, I moved the alter above the foreach loop where the views get executed. This in and of itself would make it useful for commons as it could remove unnecessary execution of views. What do you say? :)
Comment #16
ezra-g commentedThanks for the review. However, there's no attachment on #15, and the proper place to attach it is at the referenced QuickTabs issue.
Thanks!
Comment #17
RobKoberg commentedNo, I think this is an issue for commons. First, we can remove view execution for tabs we don't need. That cannot be done from quicktabs. In my case, I would have 4 unnecessary view executions done for student role'd users. I would think that would be enough to allow the alter from those who provide quicktabs in code. Attached is the patch I failed to provide earlier.
I will provide a patch for quicktabs that includes the $tabs in the alter, but that is going to have to wait until I get time to understand quicktabs more. For example, is it enough to pass the settings passed into quicktabs_build_quicktabs as the $info variable and leave that unchanged in mymodule? To me it seems this is something more deeply wrong with quicktabs. The code instance is registering itslef, so why can't quicktabs get $info from that? quicktabs made the decision not to send the $tabs in the alter. Why?
Comment #18
jasonwhat commentedHas there been updates on this? The commons browsing widgets tabs should appear in the quicktabs admin area so users can easily make changes as they need. For example, I would like to simply change "Wiki" to "Resources." I have done this in CCK and in views, but I cannot find any way to change it on a group homepage so they see a tab for "Resources" instead of "Wiki."
Any ideas how to do this?
Comment #19
RobKoberg commentedI have been seeing questions about how to modify commons going without answer. The answer is: You can't do it through the drupal web UI and expect to update commons et al. You have to do it through your whatever module's *_alter (but then things will change, so...). Commons is what it is. Love it exactly or leave it, apparently.
That being said, there is a great deal of amazing things (at least to this relative drupal newbie) that they have done to drupal. I did not know you could do the things they have done. However, and I don't know if it is drupal or a lack of foresight, but it comes at the cost of flexibility with what you want to do. It seems you must have a clone of commons, but you can choose your hair color (with the options provided).
Acquia: please correct me if I am wrong.
Quicktabs is one of most problematic dependencies with regard to affecting change. I don't get why it is used throughout.
Comment #20
jasonwhat commentedFor the most part, I second that. I understand moving things into code for the sake of speed/load times, but ultimately, why have quicktabs in code, when they could be exposed and a user could easily make changes? For the most part you can find the views and panels to edit and make changes, but there are some places that seem difficult without knowing where to look or digging into code.
Comment #21
charlie charles commented@jasonwhat
If you only want to change "Wiki" to "Resources."
you can use the https://drupal.org/project/stringoverrides
Or here's another way you can edit it
https://drupal.org/node/2085271
I hope helps
Comment #22
japerryAfter reading all of these comments, and those of #1994854: add drupal_alter('commons_bw_create_all_widget', $group, $items); in commons_bw_create_all_widget, I'm having trouble seeing why you don't use the alter from 'commons_bw_get_tab_definitions' ?
You should be able to do 'mymodule_commons_bw_group_widget_alter' to get what you're looking for. Feel free to respond with needs review or fixed if updates does what you're looking for.
Comment #23
alcroito commentedThe problem with mymodule_commons_bw_group_widget_alter is that you can only change the tabs, but not the tab style settings.
The settings are hardcoded in commons_bw_generate_group_widget(), and there is no alter anywhere to change them.
The resistance to commit the latest patch seems very counter-productive to developers who want to cleanly modify and extend Commons,
and the Quicktabs issue is almost one year old, and it doesn't seem that any progress will be done on that soon.
Comment #24
alcroito commentedI provided a working patch for the quicktabs issue here.
https://drupal.org/node/1795982#comment-8872861
Comment #25
bdupls commentedezra-g - I wonder if you could comment.
The commons group browsing widget is set in views to display teasers. However if you edit your content type teaser to include more fields it should update the browsing widget. This is a basic setting and yet it doesn't seem to affect this widget. I feel this should be a basic setting to follow other modules. Am I the only one that thinks that?
The only other way I can see, (without editing code) is to not use that widget at all and create a quick-tab and insert each content type teaser. Seems like a waste of a function?
Comment #26
sdstyles commentedRe-roll #17 patch to apply it on commons 7.3.20 without git conflicts.
Comment #27
lsolesen commented