I am creating a theme where I trying to use a page override: page--over.tpl.php to provide a specialized page. I call it with a link to ...?q=over. The page loads but it seems not to have all the variables available to it that I expected. For example, $head_title and $logged_in, among others, don't seem to be available. I also can't locate $main_menu. Other vars seem to be there, e.g.; $head, $logo, and others.
I just want to bring up a page that looks the same as my basic page except that a 'special' content area is shown on request without using block assignments or any method that requires specialized site modification after the theme is installed. Including javascript or a specialized module. It should work out of the box. Basically I am using an event (clicking a link) to modify the basic page. Perhaps that isn't the best way but the documentation is really unhelpful. Suggestions are welcome.

Comments

dcrocks’s picture

Title: Variables available to page ovrride » Theme variables not available to page ovrrides?
Category: support » bug

This hasn't gotten any comment as a support request and has become a show stopper for me. In my new site I have created 3 page tples: page.tpl.php, page--front.tpl.php, and page--home.tpl.php. The 1st 2 work fine and render as I would expect them to, but the 3rd doesn't. It acts as if it doesn't have access to all the system variables, especially $page['content']. Actually I simply duped page.tpl twice and added a different H1 to the top of each one for test purposes so I could see which is being loaded. page--front.tpl is loaded by the system as the root url. page.tpl is loaded any time I select a menu item. I use ?q=home to select page--home.tpl. As indicated before, several variables don't seem to be available, while other are. I looked at theme suggestions but can't find an example that fits my situation nor adequate documentation. I can't find anything that actually says what theme suggestions are. A good reference link would be greatly appreciated. At this point, 2 out of 3 identical page tpl's work and one doesn't and the only difference are the call method. Is this a bug? Would I find help looking at data base content?
Again, my desire is that this theme works out of the box without any manipulation of Drupal. Working with 7.x dev dated 01/19 on a mac.

dcrocks’s picture

So I am further along, With some helpful preprocess functions I can load the page when I want to load it, else drupal does its normal thing. But I still don't have some of the regular page variables available to my page. This includes variables called in html.tpl.php, such as $title. Why doesn't 'page--front' have a problem but mine does? Until someone clarifies, this still looks like a bug, not as designed.

dcrocks’s picture

Tried experiment. Installed clean copy of 7.x dev dated 01/19. Copied bartik theme folder to sites/all/themes and renamed it tikbar. Did appropriate renames in templete.php and tikbar.info. Duplicated bartik's page.tpl.php twice and renamed to page--front.tpl.php and page--extra.tpl.php. In each file added identical change so that the 'a' element href in the $logo code has ?q=extra and title field changed to reflect that file they were in. Same results as in theme I'm building. page--extra doesn't have access to the same theme variables as the other 2 and renders incorrectly. What do I need to change so that page--extra is called with the same parameters as the other 2 pages?

dcrocks’s picture

It appears that this page, which is not an override of any of drupal's predefined internal paths, has to have an entry in menu_links table to be properly rendered. And it appears that can only be done from a module.So I can't add a page override of page.tpl.php(except page--front) without writing/using a module.

Jeff Burnz’s picture

Status: Active » Closed (works as designed)

From what I recall page suggestions have only ever been based on Drupal internal paths + page--front and that's it, if you want more you need to add them via theme_hook_suggestions or add your own menu items with page callback (yes you need a module), see http://api.drupal.org/api/drupal/includes--theme.inc/function/theme_get_...

dcrocks’s picture

I found another, though not very elegant, way to do what I want. I don't think theme suggestions will work at all without an entry in the menu link table. A 'page' doesn't seem to be an object of its own in drupal and most references to 'page' seem to be actually talking about node content. Confusing when a 'page' often has multiple 'page's of content. Anyways, thanx for the confirmation.