I'm adding a new page at http://mydrupalsite.com/example. It's all static content and has a different theme so I'm defining the content in page-example.tpl.php.

But I still need to define a path for drupal to know about this page. The normal way of adding a new path is with hook_menu, but is there any other way? My problem with hook_menu is that the new path doesn't get activated unless I specify a "page callback" but I'm not sure what to put in this case since all I want is just to define a new path. Has anyone dealt with this before? I'm hoping there's a better way than hook_menu for this.

  $items['example'] = array(  
    'page callback' =>                        // don't know what to put here
    'type' => MENU_CALLBACK,
    'access callback' => TRUE,
  );

Comments

nagarajanl’s picture

No need to add a new callback, just add a dummy page from 'node/add/page', in the URL path settings specify the path as 'example'.

Also make sure your path module is enabled. Now when you request the page 'example', it will render the contents from 'page-example.tpl.php'

qler’s picture

Thanks for the reply. It creates a page at mydrupalsite.com/example, but it has the default theme not the tpl.php. Here's what I did

enabled path module
added a new node via http://mydrupalsite.com/node/add/page
specified the URL path settings to "example"
placed the page-example.tpl.php in the theme folder
reset my module and cleared cache

but I still see the original drupal theme

nagarajanl’s picture

I see what you mean, i assume that you have two different themes say default_theme, example_theme. If you want the example_theme needs to be pointed out in the 'example' url, place the below snippet in your custom module.

<?php

function custom_module_init() {
global $custom_theme;
if ($_REQUEST['q'] == 'example') {
$custom_theme = 'example_theme';
}
}

function custom_module_preprocess_page(&$vars) {
if ($_REQUEST['q'] == 'example') {
$vars['template_file'] = 'page-example';
}
}

place the 'page-example.tpl.php' in your 'example_theme' and clear the cache. Now if you visit your page mydrupalsite.com/example, it will point out the 'page-example.tpl.php' from your example_theme.