What do I do wrong?
I've a Joomla! site. Within an iFrame I show Gallery. To be able to customize Gallery for this situation, I add an extra parameter to the URL. Within main.php I test for this parameter and store it as a session variable. This works fine, to be sure I read the variable back and display it from the main.php.
But once I try to use this variable within a template, it does not work. I’ve added some debug/test info to my theme.tpl: $smarty.get.joomla_iframe works fine, but only as long as the parameter is within the URL string, which is not always the case.
Both $smarty.session.joomla_iframe and $joomlaTST don’t seem to work:
- Notice: Undefined variable: _SESSION in E:\Gallery2 Data\smarty\templates_c\theme.tpl.php on line 78
- Notice: Undefined index: joomlaTST in E:\Gallery2 Data\smarty\templates_c\theme.tpl.php on line 79
The Debug Output and Smarty Debug Console do not help me very much …
My URL:
http://www.MySite.nl/gallery2/main.php?g2_language=nl&joomla_iframe=ON
My config.php:
$gallery->setDebug('buffered');
My main.php:
/* Joomla Parameters */
global $joomla;
if ( $_GET['joomla_iframe'] <> '')
{
$joomla = $_GET['joomla_iframe'] ;
$session =& $gallery->getSession() ;
$session->put(' joomla_iframe', $joomla) ;
$ret = $session->save() ;
}
/* Process the request */
GalleryMain();
// TEST: READ BACK
global $joomlaTST;
$session =& $gallery->getSession();
$joomlaTST =& $session->get(' joomla_iframe');
echo "JoomlaTST($joomlaTST)";
My theme.tpl:
<p>Debug Info [ GET="{$smarty.get.joomla_iframe}" SESSION="{$smarty.session.joomla_iframe}" GOBAL="{$joomlaTST}" ]</p>
- Notice: Undefined variable: _SESSION in E:\Gallery2 Data\smarty\templates_c\theme.tpl.php on line 78
- Notice: Undefined index: joomlaTST in E:\Gallery2 Data\smarty\templates_c\theme.tpl.php on line 79
{if ($smarty.session.joomla_iframe == "ON")}
{* No Navigation Bar ... *}
{else}
{* Navigation Bar ... *}
G2 System Information
Gallery version = 2.2.3 core 1.2.0.5
PHP version = 5.2.4 Apache2handler
PHPInfo Link (see FAQ):
Webserver = Apache/2.2.5 (Win32) PHP/5.2.4
Database = MySQLi 5.0.45-community-nt, lock.system=database
Activated toolkits = Exif, ImageMagick, LinkItemToolkit
Operating system = Windows NT COMPAQ 5.0 build 2195
Browser = MSIE 7.05730.11 and Firefox 2.0.0.9
Posts: 32509
there's no smarty.session variable, it's as simple as that.
assign your session variables that you need in the .tpl files to $smarty (or $template).
--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage
Posts: 30
Could you give me a little hint: how to use assign my session variable to $smarty (or $template) within a .tpl file? I’m a novice for both PHP and Smarty.
Do I have to code PHP within .tpl or do I prepare a variable with main.php like I try to do now? I’m looking at example 2.9 of the documentation … But I assume a Smarty() instance must already be defined somewhere, I can’t find it ...
example 2.9
PS. Although to the documentation on the Smart Website states that a $smarty.session.variable does exist, I assume it’s not implemented within Gallery?