I recently upgraded my website to Drupal 6. Unfortunately I seem to be missing the clue on how to get access to Drupal core variables from within the front page generated by the front_page.module.
In general php works fine. If I put <?php print 'Hello world!'; ?>
inside the front page, Hello World!
will show up on the front page just as expected.
If I want the header information to be more dynamic though and put i.g. the line
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language ?>" lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
in it, the outcome will be
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="" lang="" dir="">
instead of the desired
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="" dir="ltr">
seen with the use of the garland theme.
Also the use of the variables $head_title
, $head
, $styles
, $scripts
and mostly desired $search_box
will return nothing, even when they are defined as global.
Can somebody put me back on the right track, please? Any help will be greatly appreciated. Thanks.
Comments
Comment #1
Phillip Mc CreditAttribution: Phillip Mc commentedthis is just a guess, but, you may have to call the init_theme function in your custom front page to make all the variables available.
Try inserting this line at the top:
<?php init_theme(); ?>
Comment #2
Norrin CreditAttribution: Norrin commentedThanks for trying to help, but this doesn't work, I'm afraid.
Comment #3
Dublin Drupaller CreditAttribution: Dublin Drupaller commentedyou need to call the variables directly because the front_page.module deliberately bypasses the theme engine and theme so you've got a blank canvas
As an example, to insert your styles into your front_page use the following snippet:
Styles:
print drupal_get_css();
Your search form:
print drupal_get_form('search_theme_form') ;
Language:
print $GLOBALS['locale'];
Site footer:
print variable_get('site_footer', '') ;
And so on...
Here's a quick list of variables (from the phptemplate engine):
Comment #4
Norrin CreditAttribution: Norrin commentedCool, but the use of the variables
$GLOBALS['locale']
andimplode(' | ', $head_title)
are still returning nothing.Never mind though, I'll find a solution for that too. Most important to me was the dynamic output of the styles-, scripts- and search_box-variables on the front page. This works perfectly now. So you finally brought a long and restless search to a happy ending. ;o)
Thank you ever so much for helping.
Comment #5
Dublin Drupaller CreditAttribution: Dublin Drupaller commentedyou're welcome.
not sure why your locale isn't displaying properly but as a tip what might be more efficient for what you're doing would be to copy your page.tpl.php file, call it page-front.tpl.php and edit to suit. Drupal shold automatically pick up that page template file when you upload it to your theme folder. Use THEMED instead of FULL in your front_page module settings page.
That way you have the convenience of using the front page.module to control which content is displayed while also controlling the layout in more detail. also, because you're using the theme engine, your variables should work as expected as well.
hope that helps
dub
Comment #6
Norrin CreditAttribution: Norrin commentedThat sounds very interesting. I'll give it a try in a quite moment.
Thank you once again.
Comment #7
afterdark CreditAttribution: afterdark commentedI couldn't find my front_page module settings page, where is it?
Anyway, the page-front.tpl.php seems to work perfectly, thanks for the tip, D.D.
Comment #8
Scott M. Sanders CreditAttribution: Scott M. Sanders commentedFront settings are at Admin > Site Config > Advanced Front Page Settings (alpha sort may confuse) or just admin/settings/front.
Comment #9
afterdark CreditAttribution: afterdark commentedThanks a lot for the answer, Scott. I haven't noticed that the tread was all about the front page module! Now it's installed and the changes are properly setted.
Comment #10
cazou CreditAttribution: cazou commentedHi, I can't access $language or $GLOBALS['locale'] either.
Did anyone succeed getting these variables inside the frontpage module using the page_front.tpl.php template ?
Comment #11
cazou CreditAttribution: cazou commentedOk, actually, it's not $GLOBALS['locale'] but $GLOBALS['language']...
Comment #12
Dublin Drupaller CreditAttribution: Dublin Drupaller commentedComment #13
knalstaaf CreditAttribution: knalstaaf commentedI'm having exactly the same problem as described in the very first post of this thread. I wasn't able to solve it with the given replies.
My code:
Results in:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="" lang="" dir="">
More ideas?
I'm also having trouble using custom includes (which are located in the folder of my theme). Even an include with an absolute link is not working.
Comment #14
knalstaaf CreditAttribution: knalstaaf commentedHow do you add regions in Themed-mode? My whole front-page is made in the Advanced front page settings, except for the header (so I made a page-front.tpl.php with a
<?php print $content ?>
-rule to put the rest of the page in).This method is not working, since it's meant for D5.x. Is there some documentation for D6.x available about this matter?
P.S.: the region ìs defined in the info-file.