Hello all,
I am creating a minimal theme for a small site. I am fairly new to drupal but can just about find my way around PHPTemplate.
One feature of the theme I would like to have is to allow the author to choose one of 4 background images which make up most of the content area background. When a user creates a new node they should be presented with the option of choosing a background image for the node. The background image is output as html in page.tpl.php.
I figured the best way of doing this was to create a taxonomy term for the background. I have created a vocabulary and added 4 terms with the values as the name of the jpg images; about-bg.jpg, contact-bg.jpg, etc. I am having issues getting the taxonomy data into page.tpl.php so I can extract the value and output it to select the jpg background image.
I've had a look and tried out taxonomy_node_get_terms but I cant seem to get anything out of it.
How can I get the taxonomy data available to use in page.tpl.php?
Thanks.
Comments
Try the following
Try the following code:
$taxonomy_terms will then be an array containing the taxonomy terms on the current node.
Couldn't get this code to
Couldn't get this code to work but I managed to modify it. I found that $node->taxonomy[] was keyed by the termid, not the vocabularyid. Instead I just ran through all the terms looking for the vocabularyid I needed.
Thanks for your help
inside a preprocess function instead?
The code above worked for me within page.tpl.php, but I'm curious if it's possible to do this in a preprocess function instead. I tried essentially the code above inside a theme_preprocess_page function, but I can't seem to get it working. Any suggestions?
found the answer
I found a thread that had a solution.
Thanks this worked for me!
Thanks this worked for me!
Also works for custom print tpl
Just wanted to add that this works great in a custom tpl used to output a PDF (using the Print module).
My tpl file is print_pdf.node-project.tpl.php, where "project" is my content type.
I added a print clause in the foreach loop.
- Mike
How to use arg()?
Thanks so much! This thread helped me solve an issue that I was having where I only wanted to show "Share This" button on one page. But one question that I have is, where can I go to learn more about arg() in Drupal?
Thanks,
Alvin C.
short answer
http://api.drupal.org/api/function/arg/6