• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Fixed] Smarty + CodeIgniter = extra text

#11
Or as just tested as quick example, you can use it directly (like all other classes in php):

PHP Code:
include_once(APPPATH.'third_party/smarty/Smarty.class.php');
$smarty = new Smarty;
print_r($smarty); 

Reply

#12
(01-09-2015, 11:30 AM)Rufnex Wrote: Or as just tested as quick example, you can use it directly (like all other classes in php):


PHP Code:
include_once(APPPATH.'third_party/smarty/Smarty.class.php');
$smarty = new Smarty;
print_r($smarty); 

Ive tried that tutorial, did not work :/
Gonna give it another try.


Edit:
Tried it once more, did everything exacly like the tutorial said, did not work. Same issue.
Btw the things you linked are from 2009 :p
Reply

#13
Still nothing? Ive tried at the smarty forum aswell :/
Reply

#14
Have you tried my example above directly? Btw .. there are any god reasons to use smarty intstead of ci native php style?

Reply

#15
Quote:Ive tried that tutorial, did not work :/
Gonna give it another try.


Edit:
Tried it once more, did everything exacly like the tutorial said, did not work. Same issue.
Btw the things you linked are from 2009 :p

So yes, I have :/
Well mainly since I like the way they handle variables in the tpl file, making it super easy to push strings etc to the layout like {$renderTime}, {$main}, {$head} etc etc..

I know that this has been done before, an aac system uses codeigniter + smarty, ive tried to check that code to find the troubles im having but can't find the files since I have no ide how codeigniter is built up.
Since most of the awnsers here point to that its smarty's fault, its not. I don't want codeigniter loading the content of a page, I want smarty to do that via the {$main} variable.

Hope someone has knowledge about this, any template engine should require that part of the code to be removed, otherwise both codeigniter and the template engine will load the content of the page (as mine is doing, showing the content twice).
Reply

#16
If you don't understand how CodeIgniter works well enough to do it on your own, you need to find a library that makes Smarty work with CodeIgniter. Make sure you are using the same version of CodeIgniter as is called for in the library or tutorial you are using, as 2.x may have different requirements from 3.x.

The age of a given tutorial is really only relevant if there have been significant changes in the relevant portions of the code since the tutorial was written.

No one is implying that Smarty is at fault. The issue is simply that Smarty is not built to work with CodeIgniter, so you have to have some code which makes Smarty and CodeIgniter work together. With any template library you may have functionality to load templates and set variables which are available within those templates. This functionality duplicates functionality which already exists in CodeIgniter, so you either have to override CI's functionality to adapt it to the template library, or bypass CI's functionality and use the template library's functionality directly.
Reply

#17
Thats what I wanna do, override CI's tempalte "engine/loading".
I have tried alot of diffrent codes that "should" work with these 2, even those that are really close to the versions im using.
Im really new to both CI and Smarty. Ive written everything myself in the past, but tought I would try these out since CI gives cool functions aswell as links ex /account/login insted of /account.php&login.

Smarty is a great template engine, simple to use as CI and I would love to get these 2 working, since it would make life alot easier with coding websites.

But you said "The issue is simply that Smarty is not built to work with CodeIgniter", is there any template engine that IS desgined to work with CI?
Reply

#18
Fixed:
Change:
ob_end_flush();

To:
ob_get_clean();
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.