Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can add <code>theme_preprocess_page</code> function to your theme's <code>template.php</code> file and then add your template name in templates suggestions list.</p> <pre><code>function mytheme_preprocess_page(&amp;$vars) { // you can perform different if statements // if () {... $template = 'page__front'; // you should replace dash sign with underscore $vars['theme_hook_suggestions'][] = $template; // } } </code></pre> <p><strong>EDIT</strong></p> <p>If you want to specify template name by path alias, you could write code like this:</p> <pre><code>function phptemplate_preprocess_page(&amp;$variables) { if (module_exists('path')) { $alias = drupal_get_path_alias($_GET['q']); if ($alias != $_GET['q']) { $template = 'page_'; foreach (explode('/', $alias) as $part) { $template.= "_{$part}"; $variables['theme_hook_suggestions'][] = $template; } } } } </code></pre> <p>Without this function you would have the following node template suggestions by default:</p> <pre><code>array( [0] =&gt; page__node [1] =&gt; page__node__% [2] =&gt; page__node__1 ) </code></pre> <p>And this function would apply to your node the following new template suggestions. Example node with <code>node/1</code> path and <code>page/about</code> alias:</p> <pre><code>array( [0] =&gt; page__node [1] =&gt; page__node__% [2] =&gt; page__node__1 [3] =&gt; page__page [4] =&gt; page__page_about ) </code></pre> <p>So after that you can use <code>page--page-about.tpl.php</code> for your page.</p> <p>If you want to apply <code>page--front.tpl.php</code> to your let's say <code>node/15</code>, then in this function you can add if statement.</p> <pre><code>function phptemplate_preprocess_page(&amp;$variables) { if (module_exists('path')) { $alias = drupal_get_path_alias($_GET['q']); if ($alias != $_GET['q']) { $template = 'page_'; foreach (explode('/', $alias) as $part) { $template.= "_{$part}"; $variables['theme_hook_suggestions'][] = $template; } } } if ($_GET['q'] == 'node/15') { $variables['theme_hook_suggestions'][] = 'page__front'; } } </code></pre> <p>This would give you the following template suggestions:</p> <pre><code>array( [0] =&gt; page__node [1] =&gt; page__node__% [2] =&gt; page__node__1 [3] =&gt; page__page [4] =&gt; page__page_about [5] =&gt; page__front ) </code></pre> <p>The highest index - the highest template priority.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload