I have created a module with that module I uploade images and this images are displayed in a swf file in the content-type swfgallery.

now I will implement a fullscreen node for this content-type (swfgallery)
I will do this with a costum page.tpl.php without $left $right …. the only output in
page-simpleplugin.tpl.php is $content->body.

What I have done:

   
function mymodul_preprocess_page(&$variables) {
     foreach ($variables['template_files'] as $file) {
     $template_files[] = $file;
     if ($file == 'page-node') {
        $template_files[] = 'page-'. $variables['node']->type;   
     }
    }
   $variables['template_files'] = $template_files;
} 

I put this code in mymodul.module and then I get this output with the devel modul:

Template called:
page.tpl.php
File used:
themes/garland/page.tpl.php
Candidate template files:
page-node-3.tpl.php < page-swfgallery.tpl.php < page-node.tpl.php < page.tpl.php
Preprocess functions:
template_preprocess + template_preprocess_page + swfgallery_preprocess_page + phptemplate_preprocess_page

Now I copied the page.tpl.php in sites/default/modules/mymodul/ and renamed it to
page-swfgallery.tpl.php.
I cleaned the cache.
And nothing happened drupal again used the themes/garland/page.tpl.php file

Now I tried something I copied the page-swfgallery.tpl.php in the directory themes/garland .
And it works drupal called the templated page-swfgallery.tpl.php.!

What have I to do that drupal called the page-swfgallery.tpl.php in my modules/mymodule directory

Comments

karl2011’s picture

this code helps me




  /**
   * 
   * Implementation of hook_node_info().
   */
  function simpleplugin_node_info() {
  	
  	return array(

	  	'simpleplugin_gallery' => array(
			'name' => t('Simpleplugin Gallery'), // Required.
			'module' => 'simpleplugin_gallery',  // Required.
			'description' => t('Create a Fullscreen SWF Gallery'), // Required.
			'has_title' => TRUE,
			'title_label' => t('SWF Gallery Name'),
			'has_body' => TRUE,
  	                'body_label' => t('Text'),
			'locked' => TRUE
	  	)
  	);
  }
  
  function simpleplugin_gallery_form( $node ) {
  	// Title.
  	$type = node_get_types('type', $node);
		$form['title'] = array(
			'#type' => 'textfield',
			'#title' => check_plain($type->title_label),
			'#required' => TRUE,
			'#default_value' => $node->title,
			'#weight' => -10,
			'#maxlength' => 255,
		);
		
		$form['body_filter']['body'] = array(
			'#type' => 'textarea',
			'#title' => check_plain($type->body_label),
			'#default_value' => $node->body,
			'#rows' => 6,
                        '#weight' => -9,
			'#required' => TRUE,
		);

	  return $form;
  }


//preprocess

  function simpleplugin_preprocess_page(&$variables) {
  // If this is a node page (not a list of nodes page) and
  // the node is shown in 'view' mode rather than 'edit' or whatever.
  if (isset($variables['node']) && (arg(2) === NULL)) {
    // If the content type of that one node is 'CONTENT_TYPE_NAME'.
    if ($variables['node']->type == 'simpleplugin_gallery') {
      $variables['template_file'] = 'page-simpleplugin_gallery';
    }
  }
}

/*
* Implementing of hook_theme_registry_alter
*/
function simpleplugin_theme_registry_alter(&$theme_registry) {
  $theme_hook = 'page'; // my hook name
  // Get the path to this module
  $modulepath = drupal_get_path('module', 'simpleplugin');
  // Add the module path on top in the array of paths
  array_unshift($theme_registry[$theme_hook]['theme paths'], $modulepath);
  // dsm($theme_registry[$theme_hook]['theme paths']);
}

 

this link did help me
hook_theme_registry_alter

also interresting
screencast:
Different 5.x page templates depending on node type
hook_theme and tpl.php files: registering them with drupal, and passing variables

Theming Modules in Drupal 6