User login

Variables available in _phptemplate_variables for node templates

The variables you get to play with while setting new variables are nice.

So you can do switch or if statements on $var['type'] to only provide certain variables to certain node types.

<?php
function _phptemplate_variables($hook, $vars = array()) {
  switch ($hook) {
    case 'node':
        drupal_set_message('<pre>'.print_r($vars,TRUE).'</pre>');
        break;
  }
  return $vars;
}
?>

Outputs:

Array
(
[nid] => 438
[vid] => 438
[type] => bio
[status] => 1
[created] => 1202338605
[changed] => 1204566311
[comment] => 0
[promote] => 0
[sticky] => 0
[revision_timestamp] => 1204566311
[title] => Linda Herter
[body] =>
Lots of it. Including the CCK photo field and all the filled in fields.
[log] =>
[format] => 1
[uid] => 114
[name] => lindaherter
[picture] =>
[data] => a:3:{s:11:"remember_me";b:0;s:14:"picture_delete";i:0;s:14:"picture_upload";s:0:"";}
[path] => linda_herter_0
[last_comment_timestamp] => 1202338605
[last_comment_name] =>
[comment_count] => 0
[taxonomy] => Array
(
)

[field_user_picture] => Array
(
[0] => Array
(
[fid] => 249
[title] => lindaherter.gif
[alt] => lindaherter.gif
[nid] => 438
[filename] => lindaherter.gif
[filepath] => sites/livingconversations.com/files/user_pictures/lindaherter.gif
[filemime] => image/gif
[filesize] => 94908
[view] => lindaherter.gif
)

)

[field_ageatdiagnosis] => Array
(
[0] => Array
(
[value] => 47
[view] => 47
)

)

[field_city] => Array
(
[0] => Array
(
[value] => Granger
[view] => Granger
)

)

[field_diagnosed] => Array
(
[0] => Array
(
[value] =>
[view] =>
)

)

...

[readmore] =>
[content] =>
Same as body
[date] => Wed, 2008-02-06 18:56
[links] =>
[node] => stdClass Object
(
[nid] => 438
[vid] => 438
[type] => bio
[status] => 1
[created] => 1202338605
[changed] => 1204566311
[comment] => 0
[promote] => 0
[sticky] => 0
[revision_timestamp] => 1204566311
[title] => Linda Herter
[body] =>
Same again.
[log] =>
[format] => 1
[uid] => 114
[name] => lindaherter
[picture] => sites/livingconversations.com/files/pictures/picture-114.gif
[data] => a:3:{s:11:"remember_me";b:0;s:14:"picture_delete";i:0;s:14:"picture_upload";s:0:"";}
[path] => linda_herter_0
[last_comment_timestamp] => 1202338605
[last_comment_name] =>
[comment_count] => 0
[taxonomy] => Array
(
)

[field_user_picture] => Array
(
[0] => Array
(
[fid] => 249
[title] => lindaherter.gif
[alt] => lindaherter.gif
[nid] => 438
[filename] => lindaherter.gif
[filepath] => sites/livingconversations.com/files/user_pictures/lindaherter.gif
[filemime] => image/gif
[filesize] => 94908
[view] => lindaherter.gif
)

)

[field_ageatdiagnosis] => Array
(
[0] => Array
(
[value] => 47
[view] => 47
)

)

...
All the bloody same, right?
...
[readmore] =>
[content] => Array
(
[group_account_basics] => Array
(
[field_user_picture] => Array
(
[#access] => 1
[#value] =>
Photo:
lindaherter.gif

[#weight] => -10
[#printed] => 1
)

[field_city] => Array
(
[#access] => 1
[#value] =>
City:
Granger

[#weight] => -8
[#printed] => 1
)

[field_state] => Array
(
[#access] => 1
[#value] =>
State:
IN

[#weight] => -7
[#printed] => 1
)

[field_family] => Array
(
[#access] => 1
[#value] =>
[#weight] => -6
[#printed] => 1
)

[field_occupation] => Array
(
[#access] => 1
[#value] =>
[#weight] => -5
[#printed] => 1
)

[field_hobbies] => Array
(
[#access] => 1
[#value] =>
[#weight] => -4
[#printed] => 1
)

[field_favorite_books] => Array
(
[#access] => 1
[#value] =>
[#weight] => -3
[#printed] => 1
)

[field_proudest_moment] => Array
(
[#access] => 1
[#value] =>
[#weight] => -2
[#printed] => 1
)

[field_inspiration] => Array
(
[#access] => 1
[#value] =>
[#weight] => -1
[#printed] => 1
)

[#weight] => -4
[#title] =>
[#attributes] => Array
(
[class] => fieldgroup group-account-basics
)

[#description] =>
[#children] =>
Photo:
lindaherter.gif
City:
Granger
State:
IN

[#printed] => 1
)

[group_your_relationship_with_c] => Array
(
[field_membertype] => Array
(
[#access] => 1
[#value] =>
[#weight] => -10
[#printed] => 1
)

[field_ageatdiagnosis] => Array
(
[#access] => 1
[#value] =>
Age at Diagnosis:
47

[#weight] => -9
[#printed] => 1
)

[field_survivorship] => Array
(
[#access] => 1
[#value] =>
[#weight] => -8
[#printed] => 1
)
...
[field_bestadvice] => Array
(
[#access] => 1
[#value] =>
Best advice given to me by a Survivor:
Educate yourself.

[#weight] => 0
[#printed] => 1
)

[#description] =>
[#weight] => -3
[#attributes] => Array
(
[class] => fieldgroup group-your-relationship-with-c
)

[#title] =>
[#children] =>
Age at Diagnosis:
47
Biggest Fear When Diagnosed:
I believe we all have the same reaction when we hear the “big C” word. For a brief while I thought about death, but it was short lived. My immediate fear was for my daughter and how it would change her life. She was a junior in college at the time—would I see her graduate that next year? Would I watch her walk down the aisle on her wedding day? Be there for the birth of her first child? I also saw the pain in my mother’s face each time we went for testing, treatments, etc… As a parent we never want to think about out living our children.
How did you overcome that fear?:
After hearing my cancer was late stage III I had to put all my trust in my wonderful doctor.. He treated my mom and I knew he would do everything possible to help me beat cancer. I have a strong faith so I knew the rest was in God’s hands. I needed to concentrate on a positive outcome and believe I would someday be cancer-free. That was seven years ago and so far, so good!
What got you through your cancer experience?:
Faith, family and friends!
What was the most important lesson you learned?:
I’m a fighter! I found an inner strength I never knew existed.
What would you like to tell other women who are either newly diagnosed or too afraid to seek treatment?:
Talk to other women who have been through breast cancer. Join a support group. It’s great to hear from survivors that are 3 years out, five years out and so on. This is why LivingConversations.com will be so important to women newly diagnosed—they will see hundreds of survivors telling their stories! It’s HOPE.
Best advice given to me by a Survivor:
Educate yourself.

[#printed] => 1
)

[body] => Array
(
[#weight] => 0
[#value] =>
[#printed] => 1
)

[#children] =>
Photo:
lindaherter.gif
City:
Granger
State:
IN
Age at Diagnosis:
47
Biggest Fear When Diagnosed:
I believe we all have the same reaction when we hear the “big C” word. For a brief while I thought about death, but it was short lived. My immediate fear was for my daughter and how it would change her life. She was a junior in college at the time—would I see her graduate that next year? Would I watch her walk down the aisle on her wedding day? Be there for the birth of her first child? I also saw the pain in my mother’s face each time we went for testing, treatments, etc… As a parent we never want to think about out living our children.
How did you overcome that fear?:
After hearing my cancer was late stage III I had to put all my trust in my wonderful doctor.. He treated my mom and I knew he would do everything possible to help me beat cancer. I have a strong faith so I knew the rest was in God’s hands. I needed to concentrate on a positive outcome and believe I would someday be cancer-free. That was seven years ago and so far, so good!
What got you through your cancer experience?:
Faith, family and friends!
What was the most important lesson you learned?:
I’m a fighter! I found an inner strength I never knew existed.
What would you like to tell other women who are either newly diagnosed or too afraid to seek treatment?:
Talk to other women who have been through breast cancer. Join a support group. It’s great to hear from survivors that are 3 years out, five years out and so on. This is why LivingConversations.com will be so important to women newly diagnosed—they will see hundreds of survivors telling their stories! It’s HOPE.
Best advice given to me by a Survivor:
Educate yourself.

[#printed] => 1
)

)

[node_url] => /linda_herter_0
[page] => 1
[teaser] =>
[terms] =>
[submitted] =>
[zebra] => odd
[id] => 1
[directory] => sites/lc.openzuka.com/themes/sky
[is_front] =>
)

Resolution

Comments

WOW

I had no idea this was possible!!!!! thanks Ben for the info!

Regards from Australia

Tamara

Thanks!

Really helpful piece of code. Very good way to take control of your drupal theme... I was looking for something like this a couple of month ago and I couldn't figure out how to do it... but sooner or later... everything comes :)

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.