0
votes

I am working on a module for Drupal 7. I have a template defined for my content type as node--[content type].tpl.php and placed it in the "themes/[selected theme]/template" directory. I want to keep this template in my "module" directory instead. So when the module is installed I don't have to place the file in to the selected theme folder every time. Is there a way to do this?

Thank you all in advance.

I have less than 10 rep so I cant answer my own question so I'll just modify the question

The following is working for me some how. For both case node edit form view and node view

function [content type]_theme() {
   return array(
    '[content type]_node_form' => array(
          'arguments' => array(
              'form' => NULL,
            ),
        'template' => 'node--[content type]--edit',
        'render element' => 'form',
        ),
    'node__[content type]' => array (
          'variables' => array(),
          'template' => 'node--[content type]' ,
          'base hook' => 'node',
          'path' => "sites/all/modules/[content type]_update/[content type]_update/[content type]/",
        ),
    );
}

I don't completely understand this but it's working.

2

2 Answers

0
votes

This link should get you going: http://www.wdtutorials.com/2011/06/13/drupal-7-how-create-custom-theme#.U6sZ741dXag

You basically want to create a new custom theme. In addition to the above tutorial, create a new folder 'templates' and add your .tpl files in there instead of the core themes folder.

0
votes

You can use the below format to specify the template path. Then you can place the tpl file in your module folder.

function MODULENAME_theme() {
    return array(
        'yourcustom_theme' => array(
            'template' => 'mypage', // template file called mypage.tpl.php
            'path' => drupal_get_path('module', 'MODULENAME'),
        )          
    );
}