Hello..

I want seprate page.tpl for front page in Drupal 7 .. can anybody help me how to do this.?

Comments

VMII’s picture

Drupal 6 requires page-front.tpl.php
Drupal 7 requires page--front.tpl.php

note the double hyphen in the D7 requirement.

jereoms’s picture

Looks like a bunch of documentation is still behind on this setting. This worked for me.

Researcher for Drupal 7 Hosting

VMII’s picture

Not sure what you mean with reference to the documentation. D7 template suggestions = http://drupal.org/node/1089656 and there is a double hyphen in the suggestions.

dman’s picture

It could be that due to D7s advanced theme registry caching, just making the file (as worked in D6) isn't showing up immediately. Dunno, not tried.
But you should be able to flush the theme cache somehow. visiting admin/build/themes or whatever it's called now may be enough to trigger that. Or maybe there's a button. :-)

Drupal-Tech’s picture

Thank you VM & dman for your reply
1) I have put page.front.tpl.php in my theme folder where my page.tpl.php is exists.
2) i have cleared all caches from the performance.
3) i have visited theme page. and enable/disabled theme.

but not working.

I have also read documentation of converting theme from 6.x to 7.x but no such help for this.

Still not getting how to do this.. Please help

dman’s picture

um, did you try page-front.tpl.php as per the docs? That's a dash, not a dot.

Drupal-Tech’s picture

my mistake i have put page.front.tpl.php in comment...

danreb’s picture

Investigate here - > http://drupal.org/node/674784

seems it was changed to page--front.tpl.php but I'm not sure cause I don't test it yet

Drupal-Tech’s picture

Thank you..

i have applied patch http://drupal.org/node/674784#comment-2578696

and used tpl name like page--front.tpl.php

http://drupal.org/update/theme/6/7#template_files_double_hyphen

vishalkhialani’s picture

Hi,
I want to get the same thing done but don't know where I need to apply the patch. Please advice.

cheers,
vishal

danreb’s picture

just use page--front.tpl.php and it will automatically work now.

halohaloplace’s picture

Hi all, I want my front page only fully customized, therefore would like to remove the following:

misc/jquery.js?v=1.4.4">
jquery.once.js?v=1.2">
drupal.js?lj8myy">

... but on front page only. Is this possible at all? I just found that I could do it completely customized in Drupal 6. Please help how to do this on Drupal 7. Thanks!

jeremyvanlanda’s picture

I tried (1) renaming my file page--front.tpl.php, (2) clearing cache, (3) waiting for several hours, and (4) applying the patch, yet nothing worked. Finally I went to Admin>Configuration>Site Information and even though my default front page already said "node", after I resaved that page Drupal started recognizing my page--front.tpl.php file.

BD3’s picture

Thanks for posting that ^^^. After clearing caches it still did nothing, I had to go to Site Information and save that page for it to start showing up.

jkr’s picture

Amazing... this still is necessary transferring from D6 to D7. Would have taken me hours to find it out. Thanks for pointing this out!

Anandyrh’s picture

Renaming page-front.tpl.php to page--front.tpl.php worked for me

Thanks & Regards,
AnAnD | Drupal | Photographer @ MCS | Facebook | Twitter

clarkegj’s picture

Where is this page suppose to be?

sites/all/themes/mayo ?

or

sites/defaults or someplace else

VMII’s picture

placed in the theme folder of the active theme. If the active theme maintains tpl.php files in a separate folder inside the theme folder, the page--front.tpl.php can be placed in it.

ensure to clear the theme registry/DB cache after adding new tpl.php files to ensure that they are registered in the DB.

Docs for working with template suggestions = http://drupal.org/node/1089656

no longer here 584522’s picture

subscribing

too many projects not enough time

d.novikov’s picture

If page--front.tpl.php doesn't work after clearing caches, try to resubmit Site information form with correct homepage alias.

hemant_gautam’s picture

Hi,

I have tried the same name as page--front.tpl.php. Its working fine for me. And i tried after removing one hyphen,it is not working because one hyphen supports only in D6 theme.

I think, you need you disable and enable the theme again and then clear the cache.

nathan.bolin’s picture

Worked After Clearing Cache in D7

Anandyrh’s picture

It is a good practice to clean cache every time when a template related files are edited.

Thanks & Regards,
AnAnD | Drupal | Photographer @ MCS | Facebook | Twitter

doakym’s picture

1.- Create a page--front.php.tpl
2.- Verify that in your template.php exist the next code

<?php
function THEME_preprocess_page(&$vars, $hook) {
  if (isset(
$vars['node']->type)) {
   
// If the content type's machine name is "my_machine_name" the file
    // name will be "page--my-machine-name.tpl.php".
   
$vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
  }
}
?>

3. Clear all caches.

End.

VMII’s picture

2.- Verify that in your template.php exist the next code

<?php
function THEME_preprocess_page(&$vars, $hook) {
  if (isset(
$vars['node']->type)) {
   
// If the content type's machine name is "my_machine_name" the file
    // name will be "page--my-machine-name.tpl.php".
   
$vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
  }
}
?>

The above is not required for a page--front.tpl.php file to be recognized by Drupal 7. page--front.tpl.php is a core default template suggestion.

srikanth.g’s picture

I am using the theme: https://www.drupal.org/project/bootstrap

I added the file "page--front.tpl.php" at this path : sites\all\themes\bootstrap\theme\system
But this file worked only after i delete the folder "bootstrap_subtheme".

If i need this subtheme also,shall i create the file "page--front.tpl.php" in both the locations? :
sites\all\themes\bootstrap\theme\system
sites\all\themes\bootstrap\bootstrap_subtheme\templates

VMII’s picture

The the new tpl.php should only be required in the subtheme folder.