phpBB

Development Discussion Board

phpBB's testing ground of bleeding edge code
Advanced search

template variable does not parse in included file

All style (template, theme and imageset) related questions for the new release; advice, feedback here please.

template variable does not parse in included file

Postby Aevis » Thu Apr 30, 2009 1:24 pm

Hi

I seem to miss something so obvious that i'm almost too ashamed to ask. I have the following two files:

test.php in the boards root directory
Code: Select all
<?php

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . '/includes/functions_display.' . $phpEx);

//start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

$template->assign_var('TEST',"please display something");

//output page
page_header('test');

$template->set_filenames(array(
    'body' => 'test.html',
));

page_footer();
?>

test.html in the template folder of the active style
Code: Select all
let's check the variable: {TEST}

If I point the browser directly to the file, it works and displays "let's check the variable: please display something" on a blank page. Now i want to include it into the overall_header.html by putting following code at the very end of the overall_header:
Code: Select all
<!-- INCLUDE test.html -->

The inclusion works as i get to see "let's check the variable:" on each page after the header part, however it doesn't parse the {TEST} variable. Any help is very appreciated.
Aevis
Registered User
 
Posts: 1
Joined: Thu Apr 30, 2009 1:11 pm

Re: template variable does not parse in included file

Postby Acyd Burn » Tue Jun 23, 2009 9:34 pm

The variable is only available within the page you define it in. ;) If you want it to be available on every page you need to add it to the template array in includes/functions.php - function page_header()

Image
User avatar
Acyd Burn
Server Manager
 
Posts: 1838
Joined: Tue Oct 08, 2002 5:18 pm
Location: Behind You


Return to [3.0/Olympus] Styling

Who is online

Users browsing this forum: No registered users and 4 guests