template

Node Templates by NID

  1. /**
  2.  * Override or insert variables into the node templates.
  3.  *
  4.  * @param $vars
  5.  *   An array of variables to pass to the theme template.
  6.  * @param $hook
  7.  *   The name of the template being rend

use a CCK field to switch node templates

  1.   // ----------------------------- node templates
  2.   // $vars['template_files'] holds an array of template suggestions,
  3.   // from most generic to most specific.
  4.   // Here we add our own suggestions

Fix for changing user login block template

  1. <?php
  2.  
  3. $form['name']['#title'] = $form['pass']['#title'] = '';
  4.  
  5. $form['name']['#size'] = 6;
  6.  
  7. ?>
  8. <div id="user_login_block">
  9.  
  10. <div id="user-name"><?php print drupal_render($form['name']); ?></

Overriding template suggestions

  1. function phptemplate_preprocess_page(&$vars) {
  2.   // Content switching
  3.   $vars['template_files'][] = 'page-'.$node->type;
  4. }

changing user login block template

  1. <?php
  2.  
  3. $form['name']['#title'] = $form['pass']['#title'] = '';
  4.  
  5. $form['name']['#size'] = 6;
  6.  
  7. ?>
  8. <div id="user_login_block">

CCK Text field snippet within node-<type>.tpl.php works

  1. /*
  2.  * Code for BassPlaya
  3.  * I've tested this locally and it works for me
  4.  * the first part of the condional is if it's a view it will truncate it
  5.  * to 8 chars.

node suggestions

  1. function _phptemplate_variables($hook, $vars) {    
  2.   if ($hook == 'node') {
  3.           // Here is the way to switch to a different node-<something> template based on node properties.

Node suggestions

  1.   if ($hook == 'node') {
  2.           $vars['template_files'] = array('node-'. $vars['node']->nid);
  3.                 return $vars;
  4.   }  

call template file, pass variables

  1. <?php
  2.  
  3. $text = theme('apply_template', $data);
  4. return $text;
  5.  
  6. function theme_apply_template($data) {
  7.     ob_start();
  8.     include path_to_theme().'/my-block.tpl.php';

custom node template

  1.   <div class="content">
  2.         <?php print content_format('field_buildings_img', $field_buildings_img[0]); ?>
  3.         <?php print check_markup($node->content['body']['#value']) ?>
  4.        
Syndicate content