Hello,
I would like to use the magic tabs and add something like following code in node:
print magic_tabs_get('nulajedna','10','11','12');
The output should be a node with 3 tabs which will show nodes by ID 10, 11, 12. Is it somehow possible?
Or maybe I just misunderstood the function, right now I believe that only way to do something like this is to create template for every page in template.php file in themes.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | magic_tabs_args.patch | 747 bytes | dawehner |
Comments
Comment #1
yhager commentedYou need to create a module, and prepare a function that fills in the tabs, something like:
Then, where you want to print the tabs, you can just call
print magic_tabs_get('mymodule_mytabs');Comment #2
svihel commentedThanks for answer.
Sorry for my english, I maybe put it wrong. What I really meant was - could I somehow pass the parameters from node to the code to the mymodule_mytabs function?
For example if i put this code in node body:
It would create node with 3 tabs with content based on node IDs. Meaning that I want to re-use the function every time I want to create a node with tabs, just every time with different ones.
Comment #3
yhager commentedNo, you cannot do it at the moment. This is not straight forward to implement due to ajax functionality.
I'll keep this in my task list, and as usual - patches are welcome.
Comment #4
svihel commentedThats unfortunate, but ok, thanks for info. Looking forward to see this function in next release :]
I unfortunately am not really a programer to do it myself :(
Comment #5
yhager commentedNo problem, by submitting this request you already contributed :)
If you are not a programmer, you might want to take a look at http://drupal.org/project/quicktabs which does great work in keeping tabs management PHP-free. You need to know some PHP to use this module...
Comment #6
svihel commentedI thought about this for a while and get the idea to use Content Template module with CCK Link. Goal was to create easy to operate user interface which could allow users to create tabbed node.
First I created node type, added cck Link field, allow multiple entries (each entry should contain node id). Then I created Contemplate for this content type and as Body Template I input this:
This actually work (meaning that it created tabs from nodes 49,50 and 46), so I wanted to go further and create template that will show nodes based on IDs that is submited in node. BUT there was one bug I didnt noticed at first, although code above showed tabs as they should be I later realized that when I clicked on them probably the AJAX script did something wrong and only blank space appeared. Strange thing is that the selected tab is showing all right (the right content is shown), so I'm guessing this script couldn't be completely wrong.
The final script should look somehow like this:
Comment #7
dawehnerQuick Patch: Not tested yet
I added an argument to magic_tabs_get
So we can parse $arguments into the themefunction with call_user_func_array()
When we have this functionality, things like a magic tabs panel style plugin should be possible
// not tested yet
Comment #8
dawehnerComment #9
yhager commentedI've committed a fix to the CVS (http://drupal.org/cvs?commit=141819)
I have tested this both with/without JS, with logged in and anonymous, and it seems to work. If you need this and you are brave - please try and let me know if it works.
I updated the documentation of magic_tabs_get() function (the comment above the function), and the example callback now uses arguments - please consult these two on how to use this.
Comment #10
dawehnerwait i would switch $args and $_ajax in the argument, so all current usages of the module would work without rewrite the code
Comment #11
yhager commentedTake a look at the code, I removed the $_ajax completely, so this is not a problem anymore.
Comment #12
yhager commentedTo all who subscribed to this thread - I'll appreciate if you can test the latest dev version and see if it works to your needs.
Comment #13
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #14
jwilson3First, THANKS FOR THIS CLEVER ADDITION!
I just tested it, but I didn't like the way the URL looks for the additional args, so i changed args from serialize/unserialize to implode/explode:
@ Line 108
@ Line 168
Thus for:
print magic_tabs_get('asdf','first',$node->nid);http://server/node/4011?asdf_tab=0&referer=node/4011&args=a:1:{i:0;s:4:"4011";}
... becomes ...
http://server/node/4011?asdf_tab=0&referer=node/4011&args=4011
NOTE this is untested with multiple arguments of varying TYPES, the best thing i can recommend is to just be sure to cast correctly in your callback if you need something other than text. In my case, I cast the first extra arg to an int (since its always going to be the $nid).
I'm sure if someone wanted, this could even be improved by JSON-izing the args instead of serialize or implode/explode ;)
Cheers!
Comment #15
dawehneri like this idea:
Its additional, i think a little bit faster ^^
We have to create an array out of the ; ; ; String.
This could be done with
Any other suggestions?
Comment #16
yhager commentedThe problem with the implode/explode scheme is that it is limited in the type and value of the variables themselves. For example, if you want to send an array, or a string with ';' in it, it will fail completely.
The only way I know to keep this non-JS friendly, is to send arguments on the URL, and the only safe way I know to send (unknown types of) arguments in the URL is to serialize them.
Comment #17
webinfoguy25 commentedBump...What do I place in the code to use the product description in the first magic tab?
The product description print statement is this:
print $node->content['body']['#value']So how come I can't place those values in the code below for magic tabs?
Please help me I have wasted a lot of time trying to figure this out and read alot of threads with no luck.
Thanks,