Part of the EllisLab Network
   
3 of 3
3
Yet Another Smarty Thread
Posted: 23 April 2009 09:28 AM   [ Ignore ]   [ # 21 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  145
Joined  04-22-2009

Is there any way to use last modified date?

Thanks

Profile
 
 
Posted: 23 April 2009 09:44 AM   [ Ignore ]   [ # 22 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  145
Joined  04-22-2009

I’m just experimenting right now, but soon I’ll be using it.

While doing that, I encounter an error while parsing a template in smarty where there are CI tags in it such as {elapsed_time} I can use {literal}{elapsed_time}{/literal} but I was wondering a way around this without using the literal tag.

The following is my code;

class Welcome extends Controller {

    
function Welcome()
    
{
        parent
::Controller();    
    
}
    
    
function index(){
        
        
#$this->load->view('welcome_message');
        
$this->smarty_parser->assign("message","test");
        
$data = array("message"=>"Welcome from smarty",
        
"another_test"=>"This is another test");
        
$this->smarty_parser->parse("ci:welcome_message",$data);
    
}
}

The following error is what i get from smarty engine

A PHP Error was encountered

Severity
: User Error

Message
: Smarty error: [in ci:welcome_message line 60]: syntax error: unrecognized tag 'elapsed_time' (Smarty_Compiler.class.php, line 599)

Filename: smarty/Smarty.class.php

Line Number
: 1092

Thanks in advance

Jagar

Profile
 
 
Posted: 31 August 2009 05:08 AM   [ Ignore ]   [ # 23 ]  
Summer Student
Total Posts:  22
Joined  08-21-2009

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 ?

Profile
 
 
Posted: 31 August 2009 07:05 AM   [ Ignore ]   [ # 24 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  145
Joined  04-22-2009

$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}

Profile
 
 
Posted: 31 August 2009 11:34 PM   [ Ignore ]   [ # 25 ]  
Summer Student
Total Posts:  22
Joined  08-21-2009

@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

Profile
 
 
Posted: 31 August 2009 11:48 PM   [ Ignore ]   [ # 26 ]  
Summer Student
Total Posts:  22
Joined  08-21-2009

@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

Profile
 
 
Posted: 01 September 2009 12:20 AM   [ Ignore ]   [ # 27 ]  
Summer Student
Total Posts:  22
Joined  08-21-2009

@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

——-

Profile
 
 
Posted: 27 September 2009 10:33 AM   [ Ignore ]   [ # 28 ]  
Summer Student
Total Posts:  1
Joined  09-27-2009

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?

Profile
 
 
   
3 of 3
3
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120154 Total Logged-in Users: 27
Total Topics: 126293 Total Anonymous Users: 3
Total Replies: 664185 Total Guests: 370
Total Posts: 790478    
Members ( View Memberlist )