The Problem:

I want to have a different layout for each section of the site.

I tried first with taxonomy theme and that works great but, only for the new nodes I create.

Is there a solution to create a different layout for every page in drupal?

ex:
node/add has his own layout or node/add/page has his own layout.

I hope u can help me.

Thnx

Comments

jwolf’s picture

Check out:
Using different page templates depending on the current path
http://drupal.org/node/104316

Also see:
Different node templates depending on URL aliases
http://drupal.org/node/117491

mileZ’s picture

Hi jWolf,

thank you for your replay.

I tried page-node.tpl.php and it works very well but not for the taxonomy terms.

So I also tried the second option. But I think I'm doing some (newbie) mistakes.

in My template.php I've added:

function _phptemplate_variables($hook, $vars = array()) {

  switch ($hook) {
    case 'page':
    case 'node':

      // proceed only if the path module is enabled
      if (!module_exists('path')) {
        break;
      }
    
      $url_alias = drupal_get_path_alias('node/' . $vars['node']->nid);
  
      // if there is no URL alias defined, stop processing
      if ($url_alias == ('node/' . $vars['node']->nid)) {
        break;
      }
    
      // Finally, build suggestions array. More generic paths should go first,
      // more specific last.
      // The templates filenames pattern is node_<something>_<something>
      $suggestions = array();
      $path_parts = explode('/', $url_alias);

      // sets base of filename to page or node depending on the case
      $template_filename = $hook;
      foreach ($path_parts as $path_part) {
        $template_filename = $template_filename . '_' . $path_part;
        $suggestions[] = $template_filename;
      }
    
      $vars['template_files'] = $suggestions;
      break;

  }

  return $vars;
}

but when I reload my page I have this:

Fatal Error: Cannot redeclare _phptemplate_variables() (proviously declared in c:\...\themes\mytemplate\template.php:57) in c:\...\themes\mytemplate\template.php on line 130

On line 57 I have this:


function _phptemplate_variables($hook, $vars) {
  if ($hook == 'page') {

    if ($secondary = menu_secondary_local_tasks()) {
      $output = '<span class="clear"></span>';
      $output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
      $vars['tabs2'] = $output;
    }

    // Hook into color.module
    if (module_exists('color')) {
      _color_page_alter($vars);
    }
    return $vars;
  }
  return array();
}

Do I have to delete the last one?

And how do I define:

function _phptemplate_variables($hook, $vars = array())

Thank you!!
mileZ

jwolf’s picture

Use your theme's name (Garland)

example:

function _phptemplate_variables_garland($hook, $vars = array())