0

and now i stuck in using node override with content type. I followed these step.

  1. Create new content type name post (machine name: post)
  2. Copy node.tpl.php from module to my_theme/templates/node/node--post.tpl.php
  3. Go to admin-configuration-performance and click "Clear all caches"

Well, it did not work.

Sorry for create duplicated article, but when i followed from answer, it did not work too.

5
  • If you are using Drupal 7.33 or higher you can use theme debug in your settings.php file to find the name you should be using, find out more here: drupal.org/node/223440#theme-debug Commented Jun 10, 2015 at 3:32
  • Make sure you're using the correct theme, all i can say is you're not doing it right.
    – niksmac
    Commented Jun 10, 2015 at 4:25
  • Make sure you have keep the template file in correct theme folder in parallel to page.tpl.php/node.tpl.php. By default every page goes to page.tpl.php so you should ensure you are looking at right place. Commented Jun 10, 2015 at 4:44
  • I'm using drupal commons 7.26 Also i create a sub theme call commons_child. So I need to to move the node--post.tpl.php to commons_child/theme/templates or commons_child/theme/templates/node ? Commented Jun 10, 2015 at 6:22
  • @NoSssweat Unfortunately, same issue Commented Jun 10, 2015 at 7:45

3 Answers 3

0

If you created your sub theme correctly, the sub theme is located under drupal/sites/all/themes/ and NOT in the drupal/themes folder.

So your tpl.php file needs to be in

drupal/sites/all/themes/commons_child/templates

0

If you copied the node.tpl and renamed it to node--post.tpl.php then there is no differences between the codes. So how did you find out it was not overridden?

If you have modified the code and you are sure your node template file is not overridden, I recommend you to use theme hook suggestion as follow:

Install the entity module. If the post content type has the fields: title, field_f1 and field_f2 then use this code

function YourThemeName_preprocess_node(&$variables)
{
     $node = $variables['node'];
     if($node->type == "post"){
          $variables['theme_hook_suggestions'][]='page__post__file';
          $wrapper = entity_metadata_wrapper('node',$variables['node']);
          $variables['title'] = $wrapper->title->value();
          $variables['f1'] = $wrapper->field_f1->value();
          $variables['f2'] = $wrapper->field_f2->value();
      }
  }

Now create file page--post--file.tpl.php and use the variables $title, $f1 and $f2 in it.

0

Be sure that you also have a copy of node.tpl.php in your theme folder:

NOTE: When using phptemplate node-[type].tpl.php suggestions, there must also be an original node.tpl.php template present in your theme directory or the template suggestion is ignored.

from: https://www.drupal.org/node/17565

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.