Hi
I made my own content type
template to change the teaser node

node--content-type.tpl.php

But it also changes the details page
for the teaser.

Is there a way to make a separate
template for details page?

Many Thanks and Best Regards
Charles

Comments

cfox612’s picture

The name of your template will target all nodes with that content type. I think teaser templates are titled: node--[content type]--teaser.tpl.php

So rename your template file and you should be fine.

charlie charles’s picture

Many Thanks for your help.
I've Just found out there is no teaser template
for Drupal 7

I found this post

http://drupal.org/node/396006

function mytheme_preprocess_node(&$variables) {
  $variables['theme_hook_suggestions'][] = 'node__' . $variables['type'] . '__' . $variables['view_mode'];
}

I tried adding the code to the page.tpl.php
that didn't work

Then I tried the node.tpl.php
That didn't work either.

Any suggestions?

Many Thanks and Best Regards
Charles

cfox612’s picture

I believe that code needs to be placed in the template.php file.

charlie charles’s picture

Thank you for your time and help.
I added php to the template.php
but I got this error message

"Fatal error: Cannot redeclare responsive_bartik_preprocess_node()"

Would you let me know please is this right?

<?php

function responsive_bartik_preprocess_node(&$variables) {
$variables['theme_hook_suggestions'][] = 'node__' . $variables['type'] . '__' . $variables['view_mode'];
}

function responsive_bartik_preprocess_html(&$variables) {
// Add variables for path to theme.
$variables['base_path'] = base_path();
$variables['path_to_resbartik'] = drupal_get_path('theme', 'responsive_bartik');

// Add body classes if certain regions have content.
if (!empty($variables['page']['featured'])) {
$variables['classes_array'][] = 'featured';
}

if (!empty($variables['page']['triptych_first'])
|| !empty($variables['page']['triptych_middle'])
|| !empty($variables['page']['triptych_last'])) {
$variables['classes_array'][] = 'triptych';
}

if (!empty($variables['page']['footer_firstcolumn'])
|| !empty($variables['page']['footer_secondcolumn'])
|| !empty($variables['page']['footer_thirdcolumn'])
|| !empty($variables['page']['footer_fourthcolumn'])) {
$variables['classes_array'][] = 'footer-columns';
}
}

/**
* Override or insert variables into the page template for HTML output.
*/

function responsive_bartik_process_html(&$variables) {
// Hook into color.module.
if (module_exists('color')) {
_color_html_alter($variables);
}
}

/**
* Override or insert variables into the page template.
*/
function responsive_bartik_process_page(&$variables) {
// Hook into color.module.
if (module_exists('color')) {
_color_page_alter($variables);
}
// Always print the site name and slogan, but if they are toggled off, we'll
// just hide them visually.
$variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
$variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
if ($variables['hide_site_name']) {
// If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
$variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
}
if ($variables['hide_site_slogan']) {
// If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
$variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
}
// Since the title and the shortcut link are both block level elements,
// positioning them next to each other is much simpler with a wrapper div.
if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) {
// Add a wrapper div using the title_prefix and title_suffix render elements.
$variables['title_prefix']['shortcut_wrapper'] = array(
'#markup' => '

',
'#weight' => 100,
);
$variables['title_suffix']['shortcut_wrapper'] = array(
'#markup' => '

',
'#weight' => -99,
);
// Make sure the shortcut link is the first item in title_suffix.
$variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100;
}
}

/**
* Implements hook_preprocess_maintenance_page().
*/
function responsive_bartik_preprocess_maintenance_page(&$variables) {
// By default, site_name is set to Drupal if no db connection is available
// or during site installation. Setting site_name to an empty string makes
// the site and update pages look cleaner.
// @see template_preprocess_maintenance_page
if (!$variables['db_is_active']) {
$variables['site_name'] = '';
}
drupal_add_css(drupal_get_path('theme', 'responsive_bartik') . '/css/maintenance-page.css');
}

/**
* Override or insert variables into the maintenance page template.
*/
function responsive_bartik_process_maintenance_page(&$variables) {
// Always print the site name and slogan, but if they are toggled off, we'll
// just hide them visually.
$variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
$variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
if ($variables['hide_site_name']) {
// If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
$variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
}
if ($variables['hide_site_slogan']) {
// If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
$variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
}
}

}

spideep’s picture

I put
function inmobi_preprocess_node (&$variables) {
$variables['theme_hook_suggestions'][] = 'node__' . $variables['type'] . '__' . $variables['view_mode'];
}

on my "inmobi" theme template.php
Now my node--article--teaser.php works!

Thanks

mocasalter’s picture

Thanks for sharing, that worked for me too!

deveshkumar’s picture

stystem folder- > page.vars paste code

function THEMENAME_preprocess_node(&$vars) { 
  if($vars['view_mode'] == 'teaser') {
    $vars['theme_hook_suggestions'][] = 'node__' . $vars['node']->type . '__teaser';   
  }
}

node--[content type]--teaser.tpl.php

CODE:- 

<?php print render($content['FIELD_NAME']); ?>