user3784458
user3784458

Reputation: 116

Drupal basic page doesn’t seem to use page.tpl.php

Title says it really. Basic pages created in Drupal don’t seem to use the page.tpl.php file as a template.

If I edit the html.tpl.php file, those changes apply to every page, and it causes errors when I load a basic page.

I have also tried to copy the page.tpl.php file and name it page—basic-page.tpl.php to no avail.

Any idea what’s going on?

Also, how do I go about changing the page_top variable to include more content? Lastly, the default page.tpl.php file has $page variables and things like $page_top and the like.

How would I call the title from the page only and the body text of a page only?

I’m using Drupal 7 and a custom sub theme.

The aforementioned files are in the template folder of the theme and I did clear caches when I added them.

Upvotes: 0

Views: 816

Answers (4)

Oualiid
Oualiid

Reputation: 26

active theme debug for inspecting the template source and you get a different suggestions to user it (just avoid using node/nid).

commend drush to enable theme debug drush vset theme_debug 1

Upvotes: 0

norman.lol
norman.lol

Reputation: 5374

This may depend on the theme you are using. But I guess you are actually meaning page--page.tpl.php (double dashes). Which will be taken into account after you added the following snippet to your theme's template.php. Replace MYTHEME with your theme's machine name.

function MYTHEME_preprocess_page(&$variables) {
  if (isset($variables['node']->type)) {
   // If the content type's machine name is "my_machine_name" the file
   // name will be "page--my-machine-name.tpl.php".
   $variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type; // (double underscores)
   }
}

See Template (theme hook) suggestions, where I also got above snippet from.

Upvotes: 0

WebguruInfosystems
WebguruInfosystems

Reputation: 87

page.tpl.php file common for all pages. Just print anything to the tpl and run any node of basic page as well as other content type page and check if its working or not. If page.tpl.php not working for basic page only, then check your template.php file.

For print a page title just need to use following code:

    <?php print $title; ?>

For print body text you need to use following:

    <?php print render($page['content']); ?>

Upvotes: 1

Meera
Meera

Reputation: 170

Add $conf['theme_debug'] = TRUE; in settings.php and clear cache, reload page and check view source. It will display the template file suggestions.

Upvotes: 3

Related Questions