All tabs loading?

brenda003 - July 25, 2008 - 18:41
Project:Magic Tabs
Version:5.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:yhager
Status:closed
Description

I was under the impression each tab would load once clicked, but it seems that all tabs load once activated, as well as on each tab being activated?

#1

brenda003 - July 25, 2008 - 22:42

To be more clear, with Devel on I see that all the queries are happening for all the tabs.

#2

yhager - July 26, 2008 - 05:18

The tabs are loaded by the callback function you list when you call magic_tabs_get().

The callback, upon being called, creates the full set of tabs (titles & content, with designation of the active tab) - and that is being sent back to the browser.

This is done mostly for reasons of simplicity - both for this module's code, and for the callback implementation.

#3

brenda003 - July 26, 2008 - 14:10

Hmm. So it's supposed to be that if I have, let's say, 10 tabs - all tabs are executed at the beginning, and then once I click tab #3, all tabs are executed once again, et cetera?

#4

yhager - July 26, 2008 - 14:49

Well, yes, that is how it is implemented now.

The main reason for this is simplicity. I didn't know how this module would develop, and I am open to discussion here. In my case, I found this is an acceptable overhead, YMMV.

Can you please provide more information about your case, why you need individual tab loading, and whether you think this would serve other users as well.

#5

brenda003 - July 26, 2008 - 15:37

In many cases it is an acceptable overhead, but for a higher traffic site with lots of tabs it could be an issue. Being able to have tabs load individually on each click, or in the background, would be a *huge* improvement for those situations.

What is the benefit of using this over something like JS tools tabs? It seems it's even more overhead since it's loading each tab instead of just the once and hiding them but over and over again on each tab being activated.

For example, I have tabs that are from A - Z and load content based on that. That's a lot of load. :)

I'd be interested in what other people think. Ideally, I think it'd be nice to have options for this sort of thing. I've been looking at possible ways of implementing it.

#6

brenda003 - July 26, 2008 - 15:38
Category:support request» feature request

#7

yhager - July 27, 2008 - 12:58

I can definitely see your point.

I think I will implement it by adding a paramter for the callback, that will be the active tab number.
your callback will then have to return the same tab structure as before, but only the content of the active tab will be displayed - so you can leave 'content' empty for all other tabs. You will still have to render their titles, as they are still visible regardless of the tab clicked.

If you will not want to implement this optimization, simply ignore this paramter and render all tabs every time.

What do you think?

#8

brenda003 - July 27, 2008 - 15:37

That sounds great, though I'm a little unclear on a couple things. magic_tabs_get() already has an $active parameter which is the tab number (or first/last), so if you mean adding another parameter to that it might be confusing.

This sounds great, though! Can I have it by tomorrow? Just kidding. :P

#9

yhager - July 27, 2008 - 20:12
Status:active» patch (code needs review)

Allright, I had some spare time and created this patch. I haven't tested it enough, so not committing it yet.
However, you said something about tomorrow, no?

Please test - you can see the change in the example function and learn from that how it works.

AttachmentSize
yh.patch3.35 KB

#10

brenda003 - July 28, 2008 - 08:06

This is great! I'd like to go a little further and allow for multiple parameters, though. I think this patch just changes call_user_func to call_user_func_array

This is very very handy!

#11

brenda003 - July 28, 2008 - 08:05

Oh wait..ignore that last patch. I'm way too sleepy right now, I had this working a minute ago. Will look at it in the morning.

#12

brenda003 - July 29, 2008 - 03:39

I actually have no idea what I was doing last night (kids, don't try to code on very little sleep). Anyway, I think this is good but does require a lot of handling. What about instead having another parameter on magic_tabs_get to do this automatically? What do you think?

#13

yhager - July 29, 2008 - 04:23

Anyway, I think this is good but does require a lot of handling.

Why? Your callback should work thte same as before, only you don't have to render the inactive tabs' content.

What about instead having another parameter on magic_tabs_get to do this automatically?

To do what? Please elaborate.

#14

brenda003 - July 29, 2008 - 04:57

Hmm, don't you need to check if each one is the active tab, though? Or am I misunderstanding?

#15

brenda003 - July 29, 2008 - 05:24
Status:patch (code needs review)» patch (reviewed & tested by the community)

This patch works well. I'll start a new thread for any additional requests.

#16

yhager - July 29, 2008 - 05:42
Assigned to:Anonymous» yhager
Status:patch (reviewed & tested by the community)» fixed

Committed. I updated the README with an additional example.

#17

Anonymous (not verified) - August 12, 2008 - 05:52
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.