views:

87

answers:

2

hi. i am new to drupal theming. i want to do the following: i have a product content type that i am manipulating it's node-product.tpl.php, the product content-type has a CCK field of type "Embedded Video" (using the Media module found at http://drupal.org/project/media ). since i need to wrap the "Embedded Video" field with a

tag i want to add to my node-product.tpl.php some php code that looks like these: "print theme(...)"

i found in sites/all/modules/cck/content-module file the following function:

"function content_theme() {

$path = drupal_get_path('module', 'content') .'/theme'; require_once "./$path/theme.inc";

return array( 'content_field' => array( 'template' => 'content-field', 'arguments' => array('element' => NULL), 'path' => $path, )," ...

from that code i assume that i my code should be: " print theme('content_field', $element) "

couple of questions: 1. am i on the right track ? should i use the theme function, am i am calling the right cck hook theme ? 2. assuming that i am correct, i cant tell what is the $element parameter should be, on my node-product.tpl.php i have the $node parameters that has a lot of data in it, how can i get from the $node parameter the correct $element that should be sent to the theme(...) function ? 3. is there a batter way to find out about each module registered theme hooks name and the parameters they expect to get than browsing the module's code ?

thanks for reading my long question, help will be appreciated.

+2  A: 

CCK field is available on the node object in two formats:

  • $node->field_[field_name]
  • $node->field_[field_name]_rendered

The rendered version is the themed version of the CCK field, containing all of the markup, the other version is an array containing the rendered version and other data that CCK has stored.

You should be able to do what you want without a theme function using the data that CCK has injected on the node object.

googletorp
thank you very much.
to bad i just understood it from debugging the drupal code. the $node has a field_[field_name] where i can find all the data i need to manipulate my node.tpl.php.thank you very much
A: 

Just use print_r() function next time. ;-) For example, in this case look for print_r($node) and you'll see a lot of goodies.

Olexandr Skrypnyk