[eluser]Jagar[/eluser]
Never mind I know the purpose of the second parameter of parse function. It's pretty useful.
I didn't I could assign multiple variables at once as follow:
Excellent work!
[eluser]Jagar[/eluser]
Is there any way to use last modified date?
Thanks
[eluser]sheri.nust[/eluser]
Hey
Summer Student
i have followed your steps to use smarty in CI.
I used
function index()
{
$this->load->_ci_varmap['smarty_parser'] = 'smarty';
$this->smarty_parser->parse("template.tpl", $data);
}
of my controller.
Kinldy tell me
1. what i have to used in $data variable.
2. And how i divide my page into different regions like header, footer ,content
3. what needs to be inserted into template.tpl ?
[eluser]Jagar[/eluser]
$data is where you will load your tags that will be used by smarty template, for example if you have
$data['full_name'] = "John Doe"
$this->smarty_parser->parse(“template.tpl”, $data);
somewhere in your tpl you'll have {full_name}
[eluser]sheri.nust[/eluser]
@Jagar
Thanx man.
but when i call template.tpl file , i got error
------------------
A PHP Error was encountered
Severity: User Warning
Message: Smarty error: unable to read resource: "template.tpl"
Filename: smarty/Smarty.class.php
Line Number: 1093
-----------------
In my controller i have written
$data["company"] = "EXcillo Pvt Ltd Company";
$this->load->_ci_varmap['smarty_parser'] = 'smarty';
$this->smarty_parser->parse("template.tpl", $data);
-----------------
And in application/config/smarty_parser.php file
i am using the following url for templates
$config['template_dir'] = dirname(APPPATH)."views";
as i have placed my template.tpl in application/views folder (application/views/template.tpl)
I dont know why i am getting the above mentioned error
[eluser]sheri.nust[/eluser]
@Jagar
hey In my controller i just used
$this->smarty_parser->parse("ci:template.tpl", $data);
instead of
$this->smarty_parser->parse("template.tpl", $data);
the template is working fine...
But can u sort out the above problem when i used
$this->smarty_parser->parse("template.tpl", $data);
statement
with regards
sheri
[eluser]sheri.nust[/eluser]
@Jagar
Also when i include file in template.tpl
{include file="header.tpl"}
placed in application/views folder .
the same problem occurs
-------
A PHP Error was encountered
Severity: User Warning
Message: Smarty error: unable to read resource: "header.tpl"
Filename: smarty/Smarty.class.php
Line Number: 1093
-----
[eluser]Unknown[/eluser]
hi xtramix,
I am using your solution to integrate smarty into ci, it works perfect but the following throws an error:
{include file="footer.tpl"} inside another template.tpl doesn't seem to work.
Any idea how this should be solved?
djazzc
edit:
hmm, using:
<?php echo $this->smarty_parser->parse("ci:footer.tpl", $data); ?> inside the template.tpl works, any other "cleaner" solutions?