How to use a different template to display a node in a block ?
Hi everybody, I have users profiles built with CCK (using content_profile), on their profile page, there's all CCK fields available and I'd like to have a block with this profile but less information available to display as an "about the author" block in the content created by this user. What is the way of doing this ? If I use node_view in my custom php block it will output the full profile with all fields. Reading through the developper handbook and profile.module, I will have to implement hook_theme and template_preprocess_hook to register my new template.tpl.php is it correct ? So I can write something like that function my_module_theme() { return array( 'my_module_block' => array( 'arguments' => array('node' => NULL), 'template' => 'my_module-block', ) } function template_preprocess_my_module_block(&$variables) { //set my theme variables there } There I can discover them by making a print_r($variables['node']) ? Reading through CCK 2.0 announcement http://drupal.org/node/329969, I saw a $FIELD_NAME_rendered variable, will it be available there ? And I end by creating the file my_module-block.tpl.php and I activate my new born module. Once activated, I can put this code in a php block to view the result: $node = node_load(nid); echo theme('my_module_block', $node, TRUE); Is it the best way to do this ? Have I forgotten steps ? Is there a comprehensive tutorial which will clarify my thoughts are they are pretty fuzzy at this time. Thank you very much. Nicolas
participants (1)
-
Nicolas Tostin