Drupalie
Drupalie

Reputation: 31

how to override node.tpl.php for a specific content type and display all the contents in a single page?

I am newbie to drupal . I am creating a content type "news" . Every time i created a content of type news it shows in the page like .../drupal/?q=node/6, .../drupal/?q=node/7 and so on .

What i exactly need i want to listing all those contents in a single page and edit them in a single template file. Here I am getting problem that what will be the template file name??

Attempt: I have tried with the following names and also i have "mytheme_preprocess_page()" in mytheme/template directories.

  1.node--news.tpl.php
  2.node--type--news.tpl.php
  3.node-type-news.tpl.php

This is my 
   function ppi_preprocess_page(&$variables) {
     if (isset($variables['node']) && isset($variables['node']->custom_template['und'][0]['value'])) {
     $custom_template_value = $variables['node']->custom_template['und'][0]['value'];
     $templates_directory = dirname(__FILE__)."/templates";
     $template_file_path = "$templates_directory/{$variables['node']->type}--{$custom_template_value}.tpl.php";
     $template_name = "{$variables['node']->type}__{$custom_template_value}";
     if(file_exists($template_file_path)) {
      $variables['theme_hook_suggestions'][] = $template_name;
     }
     if ((arg(0) == 'node') || (arg(1) == 'edit' || arg(2) == 'news')) {
     $vars['template_files'][] =  'page-node-edit-news';
     }
   }
}

I have also changed the $vars['template_files'][] = 'page-node-edit-news' Where i am going wrong ?

Upvotes: 2

Views: 3496

Answers (2)

Drupalie
Drupalie

Reputation: 31

This can be possible through the name like page--node--{custom_content_type}.tpl.php
In this case it shuld be **page--node--news.tpl.php**

Upvotes: 1

Alireza Tabatabaeian
Alireza Tabatabaeian

Reputation: 169

use this steps :

  1. install views module
  2. run views and views ui
  3. use the link structure/viwes
  4. make a new view of your content type
  5. ask for fields you need and then build up your page as you wish
  6. you can theme the views if you want

Upvotes: 0

Related Questions