IF Statements Hindging On Tabs
GreenLED - March 14, 2008 - 02:03
I'd like to create a statement like this...
IF (Tab A is active)
{
do this...
}
IF (Tab B is active)
{
do this...
}I'd like to put this code inside a node -- so somehow I have to make whatever tabs variables need to be available -- to be accessible from within node.tpl.php
How can I write these types of statements...
Refer to this page: This Page

Any ideas?
Any ideas?
» Respectfully, GreenLED
»
It sounds like you are trying to do something the hardway
It sounds like you are trying to do something the hardway and I am not sure it is even practical.
Since the page being displayed is related to the active menu item (this includes tabs) each page is associated with a unique path and while more than one menu item can use the same path only one can be active. This holds true if the page is a node.
You don't spell out what you are trying to do but my guess is you want different information shown based on the tab clicked. You can achieve this with one node per tab and then use the panels module (I recommend pannels 2) along with Tabs panel style module. You can also do this with a custom content type created with CCK placing various fields in groups and then using the CCK Fieldgroup Tabs module
Well -- let's see where to
Well -- let's see where to begin answering... First off, I've already tried fieldgroup tabs. That wa a HUGE disappointment. I was looking for "LOCAL_TASK" type tabs -- not ones created inside the system tabs. Therefore, that module I canned. Second, here's what I"m trying to do...
I've got views setup like thus...
URL: node/$node-type/overview ... Where type is a node type.
I have thus created tabbed nodes, which use the system type of tab. Anyways ... the REAL problem...
In each of the tabs I have (yes) specific content that i want to show, but here's the catch. I don't have enough "node modes" to accomplish it...
Here's what I'm doing...
If you looked at the page you will notice that I have...
_| View | Details | Screenshot | Download |_
The problem is that I only have "Teaser" and "Body" templates available to me. THen you will ask -- "Isn't there some cck field available for what you need?" The answer to this question is NO. The goal is to display the SAME "attachments" table that comes with the upload module on a tab -- and that currently as far as I know is not available. Everything but that is. The FileField and other attachment type modules (cck that is) will store files, but will not display the nice table type that comes with the upload module... SO, to make a VERY long story short -- I just stuck with the upload module, and then what I did was ... has 2 modes -- the "Body" which was template'd to show only the attachment was set (in views) to show up on the Download tab, THEN the "Teaser" was set to show another "custom" template which showed some text fields and their values in a nice table format. The problem is I can't seem to create a cck field that will process my code -- because it's not well... It's hard to explain all of this right here. Hopefully you understand something of what I'm trying to get at... Basically I need more "node modes" to achieve what I'm trying to do -- if you can think of a better way -- great, but I don't think so -- well I shouldn't be so pessimistic... Hopefully someone can help me here.
Look in $node->content
Look in $node->content, you can find the formatted table as $node->content['files']['value']
Right -- I realize this, and
Right -- I realize this, and that's what I've been using.. but that's not my problem. You see there are only 2 node modes (that I can display in views) -- one is FULL and the other is TEASER. What I am doing is using FULL for a totally different thing that TEASER. I can only use these two modes to show the files attachment listing. If I could use say a Text CCK field to display it by simply inputting...
<?PHP PIRNT $node->content['files]['#value']; ?>then everything would be perfect, but I can't do that. I've tried setting the input format as php (php evaluator) but no go. Now that I think about it -- I don't know ... do you guys see what I'm trying to do -- I'm trying to basically put the attachments as the full node and the "specs" as the TEASER. This way I will then simply use CCK fields for the rest of my info... If I could display things like...
<?PHP PRINT $node->nid; ?>^ Stuff like that with a CCK field then I would be happy. But I can't!
Consider the path
Consider the path of the form 'node/$node-type/overview'. This means arg(2) holds the "sub-page" you are looking at. So if you use CCK to create a content type with at least one field per sub-page and I understand you correctly then you can do this. I would make the type with one field group pre sub-page but you need at least one field per sub-page. Then if as I understand each tab is really displaying the same node but only part of it you can in node-{type}.tpl.php (replace {type} with the actual node type do something like
switch ( arg(2) ) {
case 'overview':
// Print overview fields
break;
case 'whatever':
// Priint whatever fields
break;
}
Interesting --- Someone
Interesting --- Someone actually understands what I'm doing!! Brilliant! Yes, you have understood me correctly -- so where would the above code go? Would this be placed in my node.tpl.php file?
» Respectfully, GreenLED
»
(Frankenstein Voice)
(Frankenstein Voice) GENIUS!!! GENIUS!!! She works!! Thank you very very much!!! You've solved the problem completely!
» Respectfully, GreenLED
»
Dude, this is the best piece
Dude, this is the best piece of code I've across since I loaded Drupal. It solves so many of my problems and gives me something to really work with. Thanks! Take a look at my alteration as well... Since the "View" tab doesn't really have a name (at least I don't think so) I altered the code to be able to also post particular fields IF the "regular" view tab was active -- here's my code...
<?PHP
switch ( arg(2) ) {
case 'mission':
// Print overview fields
PRINT "Mission Statement Tab Content;
break;
case '':
// Priint whatever fields
PRINT "Regular View Tab Content";
break;
}
?>
And obviously -- you need to remove the...
<?PHP PRINT $content; ?>... snippet because you are now defining your own by this code.
Thanks again!
If you want a catch all
If you want a catch all that covers arg(2) not set or set to some unexpected value change your last case statement to
default:// Priint whatever fields
PRINT "Regular View Tab Content";
break;
Excellent. One last thought
Excellent. One last thought -- how can you change the actual menu item or tab name -- which is "view" by default? Can you do that from the same node-type.tpl.php file? That's the icing on the cake for me.
» Respectfully, GreenLED
»