Closed (fixed)
Project:
Quick Tabs
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
6 Aug 2008 at 21:45 UTC
Updated:
3 Feb 2010 at 09:20 UTC
Jump to comment: Most recent file
Comments
Comment #1
rhache commentedCodexmas helped me solved this by changing the quicktabs_block function in quicktabs.module as follows.
The code below will hide the tab if the content is empty. Ideally, what we would like to see is the ability to choose the specific behavior on a per tab basis in the quicktabs settings. That way you could choose to output the tab or not if empty, and specify empty text if you want empty tabs to still be visible.
Feel free to use this code if you want to add it to the module.
Comment #2
trevorleenc commentedthis is GREAT...
just found quick tabs this morning, and have already replaced one of the "other" tab modules out there...this one is waaaay better, and this new function is just as good...
though...I noticed this odd behavior..
I have a block with three tabs now built..
subscribe rss (html block) -10
subscriptions interface (from subscriptions module) -9
subscribe newsletter (html block) -8
the subscriptions interface is not set to display on regular pages, front page, etc...so this function removes that tab from that, however, when viewing a regular page (where subs interface doesn't show), the subscribe newsletter block doesn't display it's html...this is remedied when I re-order the weights and put subs interface at the bottom (-8).
now that's well and good and all, and I can probably work with that...but sometimes, you might want to present the tab options in a certain order...
Comment #3
fishclic commentedIt works nearly perfectly with this code, thanks ;)
But a small issue :
Let's say we have 3 tabs : A, B, C.
A and C are supposed to be visible on every pages and by every users.
If B is invisible to unregistered users, then C will be empty as well for unregistered users... The C title will be here, but not the content of the block.
Comment #4
techutopia commentedSubscribing.
This would be a great addition to the module main code when sorted.
Additionally, it would be good to say whether a tab is shown or not when a user is logged in or not (or of a certain role).
Comment #5
trevorleenc commentednot showing a tabbed block inside quicktabs can be controlled by the block settings, or if you are using a view, from that particular view options.
Comment #6
daniorama commentedAny news about how to implement this feature for D6? I have a problem with OG Blocks tabs showing on public content, this would be an excellent solution. Thanks
Comment #7
bubsy119 commented? any news on this ?
Comment #8
pauln600 commented+1 for this feature in Drupal 6. I'd like to display tabs showing relevant
content in categories where relevant content exists, and in this case
it's pretty well essential for tabs not to show up when blocks are
empty.
Thanks,
Paul N.
Comment #9
Flying Drupalist commented+1 for D6 as well.
Comment #10
dmitrii commentedHere is my modification of quicktabs.module,v 1.10.2.49 2009/01/31 22:05:12 pasqualle
Automatically hide quicktabs with empty views and blocks (from anonymous visitors only)
Changed functions:
function quicktabs_render($quicktabs)
function quicktabs_render_tabpage($tab)
Comment #11
pasquallefor easier review, here is the base of solution in #10
@dmitrii your solution have the problem which I outlined here: #262886-4: Show tab according to visibility settings of contained block
and you even load every non empty tabpage twice, which I think is absolutely unwanted..
Comment #12
drupalok commentedsubscribing... could this please be taken into a release? i don't like this patching stuff... one can hardly update anymore
thanks!!!
Comment #13
pasqualle@drupalok: The solution is not good enough to be released with QT..
Comment #14
pasqualleMoving new features to 3.x version
Comment #15
gregarios commentedSubscribing... Sorry 'bout the duplicate post. :)
Comment #16
happydrupal commentedCool......Can't wait to see the new Quick Tab 3.X
Subscribing...........
Comment #17
math_1048 commentedsubscribing
Comment #18
xarbot commentedsubscribing
Comment #19
EvanDonovan commentedSubscribing. I need this to properly use Quicktabs inside Panels 3 pages when I have Views when no empty text set. (Nice specific use case :) )
Thanks so much for this module, and the patch.
Comment #20
EvanDonovan commentedFor people still on QuickTabs 2.x, here is an improved patch for this functionality. Now it will hide views when they don't have results, which was what I needed.
If anyone cares to re-roll for 3.x, that would be great, so that we could set this to "needs review".
Comment #21
pasqualledon't worry, there is no 3.x version yet. So you can post patches against 2.x
the problem described in comment #11 still exists in this patch.
requirements:
1. 'hide empty tab' setting can be used in non-ajax quicktabs only (or non-ajax tabpages only #351953: Tabpage specific AJAX Settings)
2. the tab content should be loaded only once
to achieve requirement 2 the quicktab rendering process needs to be fully redesigned..
Comment #22
EvanDonovan commentedGood point, Pasqualle. I didn't think about the situation with AJAX tabs since my site isn't using the AJAX feature. But yes, this patch won't work with AJAX.
The main advantage of my patch was simply that it fixes the issue with "empty" views. Offhand, I can't think of a way to find out whether a tab would be empty without actually loading the content.
Comment #23
pasqualleyes, we need to load the content if we want to find out whether the tab is empty, but we do not have to load it again to render it.
Comment #24
garywiz commentedPatch #20 had a number of problems for us:
At the risk of adding to the noise, here is a patch rolled which solves these problems. Empty tabs are eliminated only for non-ajax quicktabs and the tab order is renumbered so the rest of the code is none-the-wiser. Also, a general caching mechanism is added to quicktabs_render_tabpage() so that nothing is ever rendered twice during a single page build... the empty check and the tab render do not cause duplicate renders. Also, the empty check is omitted for ajax quicktabs, so those still work properly.
I am not pretending this should be part of the committed QT module... I think it is a bit of a hack, but it solved the problem for us.
Comment #25
pasqualle@garywiz: thanks for the patch, this looks much more better now. And I do not have any objections, this could be added to the module, I just have to do some testing..
Comment #26
garywiz commentedI think if it were added to the module, it would be good to have a checkbox on the admin page for a quicktab such as "Hide empty tabs (only if Ajax set to 'no')" and set something like $quicktabs['hide_if_empty'] = 1 so that it could be used conditionally.
It is also notable that it can be difficult to hide empty tabs if people aren't careful with their themes. For example, if a block is put into a tab, often block theming includes boilerplate divs, etc which may render even if the block is empty. So, I would expect some people will submit bugs against this when "visibly empty" does not mean the same as "really empty". I debated about this thinking about whether it was worth worrying about but instead decided just to modify our theme templates to check the $content variable and not render useless divs if the content were empty. This makes the pages leaner anyway and was a good change for us.
Comment #27
pasqualleyes, I agree. An explanation on the admin page should describe this problem.
If you have the time to do the "Hide empty tabs" checkbox, then please do it. Thanks..
Comment #28
EvanDonovan commented@garywiz: Thanks for the new patch. You say that it renumbers the tab order - does that mean that there might be side effects if I switch from my patch to yours?
Comment #29
garywiz commented@EvanDonavan: You say that it renumbers the tab order - does that mean that there might be side effects if I switch from my patch to yours?
Well, it may work differently, but I believe the renumbering is necessary in order to make things work right. With the patch in #20, I was seeing problem cases where if the middle tab of three were empty (and deleted), the javascript code in quicktabs.js was not working properly because the tab indices were [0,2] instead of [0,1]. The wrong tabs were being chosen as the default tab. So, I think the proper operation is that, after empty tabs are removed, tab indices should be sequential because other parts of the code depend on having no gaps in the tab order.
Comment #30
garywiz commented@Pasqualle: yes, I agree. An explanation on the admin page should describe this problem. If you have the time to do the "Hide empty tabs" checkbox, then please do it. Thanks..
Here is an updated patch that includes the admin settings to allow you to choose empty-tab behavior on a per tabset basis.
Note, this patch updates the database and requires a module upgrade. I suggest using #24 for now until Pasqualle let's us know what he thinks of this and whether it will be put into the dev version. This patch is upward compatible from the one in #24 and just adds some of the glue to make it more suitable for inclusion.
Requires testing.
Comment #31
garywiz commentedThere was a line of debugging code (a dsm) in the patch in #30. Apologies. This one fixes it.
Comment #32
pasquallecommitted with a slight modification to correctly hide the tab when the user does not have the permission to see the tab content.
http://drupal.org/cvs?commit=292078
the idea in comment #20, to hide an empty view (view with no results) is nice, but I guess there is a problem with views with exposed filters, where the resultset can be changed. Please create a new issue if you need that functionality.
Comment #34
rc2020 commentedsubscribe
Comment #35
404 commentedsubscribe