I have a custom content.
It has a field called "Unique Card" which is a Boolean.
It is either "1" (unique) or "0" (not unique).
I'm editing my node tpl for that node type.
node--netrunner-card.tpl.php
What I need to do is... if the 'Unique Card' field is "1" then I need to put an asterisk in front of $title wherever it displays.
I can hardwire some PHP in the template, but I don't think that's the best place to do this.
This is the first theme for Drupal that I have ever worked with, so be gentle... lol.
I "BELIEVE" that I need to create a special pre-process function.
However, I don't know where to do this... and I'm not sure of the functions I would use.
Basically, I just need to do something like:
if( $field_unique_card['value'] = 1)
{
$title = "* " . $title;
}
But... again... I don't know where to create this pre-process and I feel like my hack with the $title . $title thing isn't a Drupal best syntax or anything... anyone got a suggestion(s) for me?
FYI:
I am working on a copy of the best-responsive theme that I have renamed blinks-responsive.
( in case that matters )
Comments
UPDATE: Why won't this work
So I've been reading even more and I have put together what I believe should work but it doesn't seem to be.
This function is just a test. If it would work? I could do what I need to do... but it doesn't.
HELP!
Theme function with CCK field derived variable
What is you write a small function in template.php
function yourthemename_styleunique ($unique_bool)
{
if ($unique_bool == 1){return "card_unique";}
}
Then in your tpl file, just call this function and pass the field value
[div class="[[// php yourthemename_styleunique (field_view_field('node', $node, 'field_case_customer_name')) //]]"]FORM FIELD HERE[/div]
NB: using [] instead of the angle brackets
this will write a CSS class depending on the value of the cck field, and you can style as needed.
Ok...So I'm getting a little
Ok...
So I'm getting a little excited all of a sudden. I feel like I can ALMOST grasp what you're saying. And if you are correct, then I could style based on the value of any field in my node?
There are a STACK of different themeing I'm going to have to do based on individual fields in nodes.
Is there... some way... of themeing entire templates?
Meaning... I have a template for my node called Netrunner Card...
node--netrunner-card.tpl.php
Could I create different variations for the different card types?
node--netrunner-card-operation.tpl.php
node--netrunner-card-hardware.tpl.php
etc...
Then check the field and divert from the main node--netrunner-card.tpl.php based on the type of card?