View previous topic :: View next topic |
Author |
Message |
cage Smarty Rookie
Joined: 24 Apr 2003 Posts: 8 Location: Toronto .ca
|
Posted: Thu Apr 24, 2003 12:40 pm Post subject: Smarty and Frames? |
|
|
Can this be done successfully?
I've started with a php page which parses a template file. Inside that template I call another php page within the frame src tag.
eg.
<FRAMESET cols="20%">
<FRAMESET rows="180, 200">
<frame src="callLocations.php">
</frameset>
The callLocations.php in turn calls another template which would in turn display the contents for that frame.
This ends up not working as it should. Am I missing something? Any help would be most appreciated. |
|
Back to top |
|
Sri_Lumpa Smarty Rookie
Joined: 24 Apr 2003 Posts: 8 Location: Paris, FRANCE
|
Posted: Thu Apr 24, 2003 12:52 pm Post subject: |
|
|
Hi,
Post the template code (just lines in cause)
and the callLocations.php (just lines in cause)
No enoug informations for the moment... |
|
Back to top |
|
cage Smarty Rookie
Joined: 24 Apr 2003 Posts: 8 Location: Toronto .ca
|
Posted: Thu Apr 24, 2003 12:57 pm Post subject: |
|
|
At the moment it's pretty bare; just testing to see if it works or not.
index.php
require_once("Smarty.class.php");
$smarty = new Smarty;
$smarty->display("index.tpl");
index.tpl
<FRAMESET cols="20%">
<FRAMESET rows="180, 200">
<frame src="callLocations.php">
</frameset>
callLocations.php
require_once("Smarty.class.php");
$smarty = new Smarty;
$smarty->display("temp.tpl");
temp.tpl
testing this out
Those are all the files. |
|
Back to top |
|
Sri_Lumpa Smarty Rookie
Joined: 24 Apr 2003 Posts: 8 Location: Paris, FRANCE
|
Posted: Thu Apr 24, 2003 1:12 pm Post subject: |
|
|
If I understood your installation, the Smarty class not works like this.
You have to build your own class using the Smarty original one to configure with your environment.
You have to create several directories but take a look to PDF documentation for installation (examples included) at http://smarty.php.net/manual/en/installing.smarty.extended.php
Note : The HTML content should include bold text like behind :
<html>
<head>
</head>
<frameset cols = "25%,25%,*">
<frame src ="venus.htm">
<frame src ="sun.htm">
<frame src ="mercur.htm">
</frameset>
</html> |
|
Back to top |
|
cage Smarty Rookie
Joined: 24 Apr 2003 Posts: 8 Location: Toronto .ca
|
Posted: Thu Apr 24, 2003 1:25 pm Post subject: |
|
|
The installation of Smarty is fine. If I do not use frames, everything works great.
The problem occurs when I try to use a template instead of a straight up html file in the frame src tag.
My logic is thus. Once the template that includes the frame information is parsed, i need to show another frame with the data in it. The data that goes in this frame is dynamically generated thus I can't call a .html file. I must call a template file, but the only way to do this is to create another php file and call the template from there.
Perhaps I'm going about this the wrong way? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Apr 24, 2003 1:53 pm Post subject: |
|
|
cage. your logic is correct. Your frame points to a php file that instantiates the template: should work! What exactly is wrong with the output?
Your <frameset> code is broken...( or at least missing some <frame>s), so it might not look like you expect (or the browser you are using may refuse to render it.)
Also, head Sri_Lumpa's advice on building valid html |
|
Back to top |
|
cage Smarty Rookie
Joined: 24 Apr 2003 Posts: 8 Location: Toronto .ca
|
Posted: Thu Apr 24, 2003 1:58 pm Post subject: |
|
|
Hrm
I get the following error when I try to access the page:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
It doesn't say what headers are returned.
Btw, I do normally write valid xhtml code, just being lazy atm. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Apr 24, 2003 2:06 pm Post subject: |
|
|
yipes.
I assume that when you browse to http://yoursite/callLocations.php directly, you don't get errors? callLocations.php is in the same path as your frameset.php, yes? |
|
Back to top |
|
cage Smarty Rookie
Joined: 24 Apr 2003 Posts: 8 Location: Toronto .ca
|
Posted: Thu Apr 24, 2003 2:12 pm Post subject: |
|
|
Argh! Boots, you have pointed out that I'm an idiot atm. I just noticed that my .php file was in my templates directory.
I think I need a little more caffeine to wake me up this morning.
Thanks for the troubleshooting. |
|
Back to top |
|
Sri_Lumpa Smarty Rookie
Joined: 24 Apr 2003 Posts: 8 Location: Paris, FRANCE
|
Posted: Thu Apr 24, 2003 2:41 pm Post subject: |
|
|
For information, the following code should works fine :
(in fact, I didn't try it in this state because I have no access to any web server)
index.php source
<?php
require_once(".\\MySmartyClass.php");
session_start();
if(!isset($_SESSION["foo"])){
session_register("foo");
$_SESSION["foo"] = new MySmartyClass();
}
$_SESSION["foo"]->assign("sessionName", session_name());
$_SESSION["foo"]->assign("sessionID", session_id());
$cacheID = "index".session_id();
$_SESSION["foo"]->display("index.tpl", $cacheID);
?>
constants.conf
<?php
// The following repertories must have been created !!!
define("MYSITE_BASE_DIR" , "C:\\Inetpub\\wwwroot\\MySite\\");
define("SMARTY_BASE_DIR", "C:\\php\\Smarty\\");
define("MYSITE_TEMPLATE_DIR", MYSITE_BASE_DIR."templates");
define("MYSITE_COMPILE_DIR" , MYSITE_BASE_DIR."templates_c");
define("MYSITE_CONFIG_DIR" , MYSITE_BASE_DIR."configs");
define("MYSITE_CACHE_DIR" , MYSITE_BASE_DIR."cache");
?>
MySmartyClass.php source
<?php
include_once(".\\configs\\constants.conf");
require_once(SMARTY_BASE_DIR.'Smarty.class.php');
class MySmartyClass extends Smarty {
function MySmartyClass(){
$this->Smarty();
// Smarty using directories
$this->template_dir = MYSITE_TEMPLATE_DIR;
$this->compile_dir = MYSITE_COMPILE_DIR;
$this->config_dir = MYSITE_CONFIG_DIR;
$this->cache_dir = MYSITE_CACHE_DIR;
// Smarty configuration
$this->caching = TRUE;
$this->debugging = FALSE;
}
}
?>
index.tpl source
{* Smarty *}
<HTML>
<HEAD>
<TITLE>My HomePage</TITLE>
</HEAD>
<BODY>
<TABLE CLASS="MyFrames">
<TR>
<TD>
<IFRAME NAME="Frame1" SRC="frame1.php?{$sessionName}={$sessionID}">
</IFRAME>
</TD>
<TR>
<TD>
<IFRAME NAME="Frame2" SRC="frame2.php?{$sessionName}={$sessionID}>
</IFRAME>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
frame1.php source
<?php
include_once("MySmartyClass.php");
session_start();
if(!isset($_SESSION["foo"])){
// Direct access to frame is forbidden
// Manage error...
}
$cacheID = "frame1".session_id();
$_SESSION["foo"]->display("frame1.tpl", $cacheID);
?>
frame1.tpl source
<HTML>
<HEAD>
</HEAD>
<BODY>
Current user is identified by the following sessionID : {$sessionID}
<BODY>
</HTML>
Idem for frame2 files than for frame1 files
Sorry, it was a little long, but I'm at work |
|
Back to top |
|
cage Smarty Rookie
Joined: 24 Apr 2003 Posts: 8 Location: Toronto .ca
|
Posted: Fri Apr 25, 2003 1:43 pm Post subject: |
|
|
Thanks for the detailed response Sri_Lumpa.
I was able to get these frames working and now ran into another little problem. Hopefully this will make some sense.
eg. this is pseudo code for the most part
index.php
smarty->assign("title","title");
smarty->display("frameset.tpl");
frameset.tpl
<frame name="left" src="callLocations.php">
callLocations.php
smarty-display("Locations.tpl");
Locations.tpl
{$title}
Now the problem is that I cannot pass the data from the original (index.php) to the Locations.tpl file. Since the Locations template is not called directly from the index.php the variables are not passed.
My question is: Can this be done?
I want to use frames but you must jump through a couple of hoops to get them displaying properly because of the use of templates. |
|
Back to top |
|
Sri_Lumpa Smarty Rookie
Joined: 24 Apr 2003 Posts: 8 Location: Paris, FRANCE
|
Posted: Fri Apr 25, 2003 1:53 pm Post subject: |
|
|
That's the aim of passing session ID to frames files.
PHP files (which call frame templates) retrieve the Smarty object registered in the user session (add session parameters to URL make the session_start() function recognize session data) and so, to the templates... |
|
Back to top |
|
gloot Smarty n00b
Joined: 03 Aug 2011 Posts: 1
|
Posted: Wed Aug 03, 2011 3:13 pm Post subject: Re: Smarty and Frames? |
|
|
cage wrote: | Can this be done successfully?
I've started with a php page which parses a template file. Inside that template I call another php page within the frame src tag.
eg.
<FRAMESET cols="20%">
<FRAMESET rows="180, 200">
<frame src="callLocations.php">
</frameset>
The callLocations.php in turn calls another template which would in turn display the contents for that frame.
This ends up not working as it should. Am I missing something? Any help would be most appreciated. |
You Must create and save you php file as utf8 but not bom; also your template file; you can edit you php files with EditPlus!!! |
|
Back to top |
|
shital Smarty Rookie
Joined: 06 Nov 2012 Posts: 7
|
Posted: Tue Nov 06, 2012 9:24 am Post subject: |
|
|
Sri_Lumpa wrote: | For information, the following code should works fine :
(in fact, I didn't try it in this state because I have no access to any web server)
index.php source
<?php
require_once(".\\MySmartyClass.php");
session_start();
if(!isset($_SESSION["foo"])){
session_register("foo");
$_SESSION["foo"] = new MySmartyClass();
}
$_SESSION["foo"]->assign("sessionName", session_name());
$_SESSION["foo"]->assign("sessionID", session_id());
$cacheID = "index".session_id();
$_SESSION["foo"]->display("index.tpl", $cacheID);
?>
constants.conf
<?php
// The following repertories must have been created !!!
define("MYSITE_BASE_DIR" , "C:\\Inetpub\\wwwroot\\MySite\\");
define("SMARTY_BASE_DIR", "C:\\php\\Smarty\\");
define("MYSITE_TEMPLATE_DIR", MYSITE_BASE_DIR."templates");
define("MYSITE_COMPILE_DIR" , MYSITE_BASE_DIR."templates_c");
define("MYSITE_CONFIG_DIR" , MYSITE_BASE_DIR."configs");
define("MYSITE_CACHE_DIR" , MYSITE_BASE_DIR."cache");
?>
MySmartyClass.php source
<?php
include_once(".\\configs\\constants.conf");
require_once(SMARTY_BASE_DIR.'Smarty.class.php');
class MySmartyClass extends Smarty {
function MySmartyClass(){
$this->Smarty();
// Smarty using directories
$this->template_dir = MYSITE_TEMPLATE_DIR;
$this->compile_dir = MYSITE_COMPILE_DIR;
$this->config_dir = MYSITE_CONFIG_DIR;
$this->cache_dir = MYSITE_CACHE_DIR;
// Smarty configuration
$this->caching = TRUE;
$this->debugging = FALSE;
}
}
?>
index.tpl source
{* Smarty *}
<HTML>
<HEAD>
<TITLE>My HomePage</TITLE>
</HEAD>
<BODY>
<TABLE CLASS="MyFrames">
<TR>
<TD>
<IFRAME NAME="Frame1" SRC="frame1.php?{$sessionName}={$sessionID}">
</IFRAME>
</TD>
<TR>
<TD>
<IFRAME NAME="Frame2" SRC="frame2.php?{$sessionName}={$sessionID}>
</IFRAME>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
frame1.php source
<?php
include_once("MySmartyClass.php");
session_start();
if(!isset($_SESSION["foo"])){
// Direct access to frame is forbidden
// Manage error...
}
$cacheID = "frame1".session_id();
$_SESSION["foo"]->display("frame1.tpl", $cacheID);
?>
frame1.tpl source
<HTML>
<HEAD>
</HEAD>
<BODY>
Current user is identified by the following sessionID : {$sessionID}
<BODY>
</HTML>
Idem for frame2 files than for frame1 files
Sorry, it was a little long, but I'm at work |
Quote: | in ABOVE code in constants.conf there is two lines MYSITE_BASE_DIR and SMARTY_BASE_DIR .what path i have to give ?i am working on centos..so what can be the path????? | [/code] |
|
Back to top |
|
|