Using Smarty 3 in Codeigniter 2 (a really tiny CI library)

Codeigniter is an awesome framework, it’s idea of a parser library that ships with it is not. I have written a simple library that extends Codeigniter’s native view loading to allow you to use Smarty 3 in your Codeigniter projects to render your views.


  • Codeigniter 2.0 as this library uses the core and third_party folders, although with some changes it will work with 1.7.2 / 1.7.3 versions of Codeigniter.


  • Extends native Codeigniter view loading so you can still use $this->load->view() to load your templates. This also means that if your Codeigniter application is using $this->load->view() you won’t need to change any of your code to use this library.
  • Allows you to use Smarty specific features including template inheritance inside of your views.
  • Uses your views directory for loading templates but the location of views can be changed if you don’t use the standard CI views folder.
  • Comes bundled with the latest version of Smarty already.


Copy all of the files from the download zip off the repo into your application directory. Then you should be able to just load Smarty views using the native $this->load->view() notation.


Download this library fresh off the press on it’s own Github repository, here.

Update Log:

  • Thursday, 17th February 2011 – Added in configuration file. Added in default needed cache directories. A change to note from a few days ago is the CI superobject is assigned by reference to the views using the variable name “this” which means you should be able to go $this->load->view() inside of your views or any other native CI stuff (all untested though).
  • Friday, 3rd December 2010 – Added in check for a file extension, if no file extension is found views will search for a file with a .php extension much like standard CI view loading works.

Feel free to post improvements and recommendations below if you’ve made some improvements or found that it doesn’t function correctly.

Note: Keep in mind that in this package I am using a custom MY_Loader file in the core directory to extend the native view functionality of Codeigniter, so if you are using Modular CI, Modular Extensions or already have a custom MY_Loader file in your core directory you might want to copy and paste the code into the pre-existing file yourself or you may lose existing functionality.

94 responses to “Using Smarty 3 in Codeigniter 2 (a really tiny CI library)”

  1. rick says:

    Hi Dwayne,

    Great thanks for your plugin.

    However, I found something might be a bug:
    in application/libraries/Smartyp.php

    $this->compile_dir = SYSDIR.”cache/smarty/compiled”; // Where templates are compiled
    $this->cache_dir = SYSDIR.”cache/smarty/cached”; // Where templates are cached

    the SYSDIR is Name of the “system folder” without ending ‘/’

    Is it should be $this->compile_dir = SYSDIR.”/cache/smarty/compiled”; ?

  2. Dwayne says:

    Hi Rick,

    You are absolutely correct. I might just change it to be BASEPATH.”cache/compiled” instead which should work because BASEPATH is the path to the system folder and is used in the index.php bootstrap file to include the main Codeigniter core files. Thank you for pointing out the error, I am going to fix it now and re-upload the file.

  3. edzjins says:

    hi! might actually sound dumb because i’m quite like a beginner to CodeIgniter (been working with Smarty before tho, but it was already set up), but – how do I make it work and use it?

    I’ve downloaded your package, put all the files in the needed location, and inluded “smartyp” library in autoload libraries. don’t get any errors yet, but any changes neither. if that’s correct – what’s the next step and how does it improve the whole thing?

    thank you in advance, been trying to combine them two for almost a week already, and haven’t succeeded, really, i need some help with this, already driving me crazy..


  4. Dwayne says:

    Hi Edzjins,

    In the zip file if you look in the controllers folder you will notice a test controller would have been copied over called “smartytest” without the quotes of course. Try visiting the url you installed Codeigniter and the Smarty library in and visiting the test controller. You should see the test page.


    (If you haven’t removed the index.php file)

    (If you have removed the index.php file)

    This library basically overwrites the $this->load->view call you will be making to load views in your controllers and allows Smarty to parse your view files instead letting you have greater and cleaner control over your views.

  5. edzjins says:

    Hi Dwayne,

    Thanks for the quick answer, really appreciate that.

    I open the both links, but all I see is an empty page. As I understand, there should be some header text and some body text appearing, but it itsn’t. When I view the source of the page, it’s just nothing. Not even the tag etc. What could be the problem?

    Thanks again!

  6. edzjins says:

    Hi Rick,

    Yep, checked the log, no errors. And, the folder is 777. Really strange, because there seem to be no errors, the folders are just fine, but it’s just… not working!

  7. Code Junkie says:


    Have you still got the welcome controller that came with Codeigniter? Open up the welcome view file in your views folder and edit the file to use Smarty variables and remove the PHP code and see if that works.

  8. edzjins says:

    No, I’m already having my created controller, let’s call it Blog. Works fine with the controller calling “head, $data”, “body, $data” and “foot” views from each function. “head” and “body” views use the CI-way of displaying the passed variables just fine, when I try to replace them with smarty-style variables in the views, they just output like a text, for example, “{$title}”, and that’s all.. no errors show etc. nothing hangs up either. just don’t know what to do now, when got it all set up etc.

    when I copy the MY_Loader.php file to /application/libraries/, everything goes white, i guess that means it’s broken. I decided to check CI User Guide and see what it says about extending core classes, and it has quite a different way of doing it than this solution.. i tried to change this one to the way it tells in the user guide, but no success, the same result.

    am i the only one getting a result like this? as i see, if you’re even on the smarty home page, this should be something cool, and people have good feedback about this. i guess i’m just damned not to be able to succeed to finish this project till deadline..

  9. Code Junkie says:

    You are using Codeigniter 2.0 right? Not 1.7.2? You should be able to just copy the folders from within the zip file into your application directory. In CI core libraries like custom MY_Loader’s and controllers go into the core folder not libraries.

    How is what the author has done in relation to extending the core class different than what the documentation says? I’m not really a CI expert, but I do know it pretty well and I can’t see any issues with how the author extends the CI_Loader core class.

  10. Dwayne says:


    As Code Junkie has “kindly” said you must be using Codeigniter 2.0. The guide you were viewing is for the latest version of Codeigniter which is 1.7.2 or was it 1.7.3? I don’t remember. You can get Codeigniter 2.0 from this url: – it’s stable, so don’t worry.

    I’ve also added an update log to this post as well and soon will be adding a version without Smarty bundled.

  11. edzjins says:

    Yes, all I had to do was an epic facepalm when I realised I’ve been trying to set it up for CI 1.7.3, sorry for wasting your time with that πŸ™‚ Really, didn’t mention that as it was quite late and my brain couldn’t figure that out.. Gonna set it up for CI 2.0 now, and post the result when done. Thanks again for your responses though!

  12. Go-Trex says:

    Hi, first of all thanks for creating this simple way to integrate Smarty 3 in CI 2. I have a question about using your method in combination with for example the form helper .

    When I put this in the view it will be hardcoded in the source of the file. Is there another approach to achieve this?

    Thanks in advance for your reaction.

  13. Dwayne says:


    This library will work with Codeigniter 1.7.2 or 1.7.3 just by moving a couple of files. The examples are extending CI_Controller and CI_Model inline with the new Codeigniter 2.0 changes, so changing them to extend Model and Controller will make the examples work.

    Moving MY_Loader from the core directory inside of the zip file to your Libraries folder and then placing the Smarty lib files inside of a folder called Smarty inside your libraries folder and changing the include path to reflect the new location of the Smarty files.

    @Truth BeaRAWR!,

    Dude, take a chill pill. It’s just the Internet, calm down.


    You can use helper functions inside of your views b placing the function inside of the curly braces. For example to the use form open helper function in your Smarty files simply do the following:

    This goes for any other functions as well. If you want access to the Smarty object I would store an instance in a variable called CI and pass that to the view so you can do things like $CI->config->item(‘itemname’), etc.

  14. Go-Trex says:

    Hi Dwayne,

    Thanks for your reaction. The helper part is clear to me but for example in the welcome_message.php file there is `elapsed_time` You mentioned something about storing an instance in a variable called CI which would be $CI = & get_instance() in the contructor I think.

    When I modify elapsed_time to {$CI->elapsed_time} I’m still getting an error. Is this not what you meant in the previous comment?

  15. Dwayne says:

    Hi Go-Trex,

    For this I have a MY_Controller which basically sets up some info to pass through to my views when needed. Here is how I do it:

    $this->data[‘CI’] = &get_instance();
    $this->data[‘elapsed’] = $this->data[‘CI’]->benchmark->elapsed_time(‘total_execution_time_start’, ‘total_execution_time_end’);
    $this->data[‘memory’] = ( ! function_exists(‘memory_get_usage’)) ? ‘0’ : round(memory_get_usage() / 1024 / 1024, 2) . ‘MB’;

    Then I can pass $this->data to my views when loading them and then be able to display page loading and memory usage by using {$elapsed} and {$memory} inside of my views. For accessing other CI stuff, I use: {$CI->whatever}

  16. Go-Trex says:

    Thanks for your reaction, it’s very clear to me now. I’ve changed the welcome_message.php to this:

    public $CI;

    function __construct()
    $this->CI = &get_instance();

    function index()

    $data[‘elapsed_time’] = $this->CI->benchmark->elapsed_time(‘total_execution_time_start’, ‘total_execution_time_end’);
    $this->load->view(‘welcome_message’, $data);

    I did not use a MY_Controller.

  17. Dwayne says:


    Fantastic, glad you worked it out. If you plan on needing access to the CI instance inside of multiple views I recommend you use a MY_Controller otherwise you’re violating DRY in your controllers by repeating the same piece of code multiple times every time you want to access the Smarty instance.

  18. Go-Trex says:

    Hi Dwayne,

    Could you give a quick example on how to achieve this you mentioned in your last comment. I think more readers of your blog would love to know how to extend it a bit more further so to autoload your way to integrate Smarty 3 and see the welcome_page without any errors like it is now when autoloading your method.

    Thanks in advance for your reaction again.

  19. Go-Trex says:

    Fantastic, glad you worked it out. If you plan on needing access to the CI instance inside of multiple views I recommend you use a MY_Controller otherwise you’re violating DRY in your controllers by repeating the same piece of code multiple times every time you want to access the Smarty instance.

    Hi Dwayne,

    Thanks for your reaction. Could you explain in a small blog post or reaction how to use a MY_Controller in combination with your Smarty 3 integration method. I think more readers of your post would find it handy to know how this works without violating DRY. For example could you make the welcome page without any Smarty 3 erros given because ‘elapsed_time’ is nog Smarty variable of passed trough variable.

    Thanks in advance for your reaction and keep up the good work!

  20. Go-Trex says:

    Looks like the CI 2.0 branche is removed from Is there another place available to download the CI 2.0 branche?

  21. Dwayne says:


    Codeigniter 2.0 is still on the repository, under the branches dropdown at the top select ‘tip’ and that is the current development version of CI 2.0. Mercurial is one confusing beast, don’t be alarmed seeing changes for CI 1.7.3 and whatnot as they don’t apply to the tip branch.

  22. Shaun B says:

    Just used this library. Fast install and flawless. Thanks very much! πŸ™‚

  23. Tac says:

    Great utility, Dwayne, thanks. I made an addition My_Loader:

    function assign() { // pass-thru to Smarty assign
    $CI = & get_instance(); // Get instance of the Codeigniter object
    $CI->load->library(‘smartyp’); // Load our Smarty parser library
    call_user_func_array(array($CI->smartyp, ‘assign’), func_get_args());

    Which allows you to assign data the same way you do in Smarty, which is sometimes easier than building up a big $data variable and passing it. You also get the cache control and the flexibility to pass pairs or arrays, e.g.

    $this->load->assign(‘title’, “Page Title”);
    $this->load->assign(array(‘h1’=>”Content Header”, ‘body’=>”Item Description Here”));

    Is this the best place to post things like this? I think I saw a forum about this library, that might be better for a discussion, especially since this is not a particularly friendly thread (can you delete the inappropriate comments, they’re distracting).


  24. Dwayne says:

    Thanks for the addition Tac. I’ll implement the additions when I get a chance too, but to anyone else reading the comments your additions will help until I’ve added them in. I’ll also delete the bad comments, great suggestion.

  25. bradly says:

    hello thanks so much for your library,
    but i have a question , how can i load a view file from the view folder
    or a language variable or config variable?
    can i do this

  26. Dwayne says:

    Unfortunately the easiest way to do this is to set up some variables in your controllers like so:

    $data[‘config’] = $this->config;
    $data[‘lang’] = $this->lang;

    Then pass through the $data variable when loading your Smarty view.

    I haven’t tested, but that should work. Then you should be able to go in your Smarty views:

    {$config->item(‘foo’)} and so on. It should work, if not you can always pass through the CI object by reference to your views as $CI and then use $CI instead of $this in your views.

  27. bradly says:

    thanks very much it work fine now

  28. Michael says:

    Is there anyway that you can switch between CI’s native view function, just having pure PHP in your view files, and then having Smarty view files?

  29. Code Eater says:


    What do you mean? Do you mean that you want to have PHP view files and Smarty view files? Why can’t you just put PHP code in your Smarty views?

  30. Owen says:

    I would also like to use both Smarty & CI views.
    Changing the MY_Loader function name to view_smarty() rather than overriding the native view() seems to work for me although I have only run a simple test so far.
    Separating the Smarty view files with .tpl also saves confusion (and makes syntax highlighting easier in my ide).

    Thanks Dwayne, this library is really helpful!

  31. Raffael says:

    I get a lot of Permission denied errors.
    The official Smarty doc tells me to create the following dirs:

    $> mkdir smarty/templates
    $> mkdir smarty/templates_c
    $> mkdir smarty/cache
    $> mkdir smarty/configs
    $> chown nobody:nobody smarty/templates_c
    $> chown nobody:nobody smarty/cache
    $> chmod 775 smarty/templates_c
    $> chmod 775 smarty/cache

    Could you tell me where to put them exactly? Into the root dir or into the third_party dir?

  32. Dwayne says:


    Yep. Renaming the function in the MY_Loader to view_smarty() will still work fine and you shouldn’t notice any issues. I might add a config option to allow you to switch this on and off perhaps.


    I have updated the post with a link to the repo this library is now hosted on. If you look inside of the download, you should see the cache directories are now all set up and you might just have to set the permissions on them.

    The cache directories by the way go into application/cache

  33. levent says:

    A PHP Error was encountered

    Severity: Warning

    Message: mkdir(): Permission denied

    Filename: sysplugins/smarty_internal_write_file.php

    Line Number: 28
    A PHP Error was encountered

    Severity: Warning

    Message: rename(/tmp/wrtkm2VMJ,/home/lev/public_html/ci2/system/cache/smarty/compiled/a11c158f07695acc0868baf9a1e2cda542f0cba7.file.smartytest.php.php): No such file or directory

    Filename: sysplugins/smarty_internal_write_file.php

    Line Number: 48
    A PHP Error was encountered

    Severity: Warning

    Message: chmod(): No such file or directory

    Filename: sysplugins/smarty_internal_write_file.php

    Line Number: 50

    I changed the permissions of the /application/ directory to 777 but still got these errors. I moved all files and directories to the corresponding place in ci2 and autoloaded the “smarty” library.

  34. levent says:

    Now it works. I changed the permissions of /system directory writeble.

  35. Andreas says:

    Great work!
    Works fine.

    I have the need of good formvalidation. And have been searching a lot on the web, about smarty, validation, codeigniter, jquery and so on but many of the results are verry old, or they are verry complicated.

    I would like to have a pretty simple way to achieve this, just add requirements and/or the range and so tho the smarty template. And then it should work. The best would be if I got an ajax validation that check the inputfields and so when the user is typing or clicking.

    Do you or anyone else has any recomendation to some tool or plugin that does this.

    regards Andreas

  36. levent says:

    I forgot but thank you for this great work @Dwayne.

  37. Error handling says:

    Is there something you / I can do with error handling?

    If something happens now I get a nasty [i]Uncaught exception ‘SmartyException’ with message[/i] message.

  38. Error N00b says:

    Error Handling,

    Maybe if you typed a descriptive and coherent answer, Dwayne might be able to answer you properly…

  39. Code Eater says:

    @Error handling – Are you talking about Smarty throwing errors for variables that don’t exist? Simply set the value of Smarty to not show exceptions and your errors should vanish. “$this->exception_handler = null;” throw that into the constructor of the CI_Smarty library in the libraries folder.

  40. Matt says:

    The latest build on github needs an update for it to work properly.

    /libraries/MY_Parser.php : line 51
    – $this->smarty->assign($key, $val);
    +$this->ci->smarty->assign($key, $val);


  41. vincenzo says:

    Is possibile with this library use two different theme. Can i switch it from a controller with a set->theme for example….


  42. Dwayne says:


    This library is merely for rendering the templates, it doesn’t have theming capabilities that part is up to you. With a few modifications Phil Sturgeon’s template library should work with it quite fine or with any templating library for Codeigniter that has parser support.

  43. vincenzo says:

    I don’t know how, have you got a wiki about it…


  44. Dwayne says:


    Go here for Phil’s templating library: – it supports themes and layouts, etc. With some modification (maybe) you can make it work with this library too. If this is a requested enough feature, I’ll implement true support into the library.

  45. Hi Dwayne,

    Really GR8 work! Minimal Configuration!

  46. r-benTahir says:

    Mr,Dwayne.. what a great job you did.. Codeigniter and Smarty that is a “waaoow” combination.. Thanx to you people that we can enjoy codeigniter. God bless yi.

  47. Alexander84 says:


    outputs as follows before template processing

    A PHP Error was encountered
    Severity: Warning
    Message: Missing argument 2 for MY_Parser::parse(), called in somepage_controller.php on line 6 and defined

    Filename: libraries/MY_Parser.php
    Line Number: 22
    A PHP Error was encountered
    Severity: Notice
    Message: Undefined variable: data

    Filename: libraries/MY_Parser.php
    Line Number: 44
    A PHP Error was encountered

    Severity: Warning
    Message: array_merge() [function.array-merge]: Argument #1 is not an array
    Filename: libraries/MY_Parser.php
    Line Number: 44

    It seems some arguments like $data are missing in controller, but I just want to parse a couple of templates without passing variables like I do with other template engines such as Dwoo. Any clues how to overcome these warnings?

  48. Alexander84 says:

    Dwayne, please check CI library of Dwoo’s template engine -> -> Dwootemplate.php
    as well as Seldaek’s comment in thread about ampersand near $CI = get_instance().

    As you can see, library Dwootemplate.php is neither split into two files (MY_parser+Smarty), nor it requires $data argument obligatory. Could you be so kind and take best of it into your Smarty3 adapter for CodeIgniter?

  49. Anks says:

    Hi Dwayne,

    I just wanted to thank you for a great Smarty-CI integration solution. Installation was very smooth, just one bug(!?I think!).
    $this->ci = CI_Base::get_instance();
    doesn’t work.
    $this->ci = & get_instance();
    works. Not sure what’s the difference b/w two methods. Thanks once again.


  50. Code Junkie says:

    Not sure if everyone knows this already, but Dwayne has made a library for Codeigniter called Plenty Parser which is driver based and lets you render views using Twig or Smarty, it’s friggin’ amazing.

  51. Andre says:

    Hello. I have problem about smarty & CI. There are error as
    ‘A PHP Error was encountered

    Severity: Warning

    Message: array_merge() [function.array-merge]: Argument #2 is not an array

    Filename: libraries/MY_Parser.php

    Line Number: 49’

    It is tested on localhost while I tried “http://localhost/newsite2/index.php/smartytest”


  52. There’s a tiny error in the MY_parser file from the library folder.
    On line 49 a “;” was forgotten

  53. Dwayne says:

    Thanks guys, that was a result of a pull request someone else made and I didn’t actually notice. All fixed now and pushed to the repo, enjoy.

  54. Francisco says:

    Hello. The errors persist.

    I’m getting these:

    Severity: Notice
    Message: Undefined property: MY_Parser::$load
    Filename: libraries/MY_Parser.php
    Line Number: 49

    Severity: Notice
    Message: Trying to get property of non-object
    Filename: libraries/MY_Parser.php
    Line Number: 49

    Severity: Warning
    Message: array_merge() [function.array-merge]: Argument #2 is not an array
    Filename: libraries/MY_Parser.php
    Line Number: 49

  55. Francisco says:

    Change line 49 with the following:

    $data = array_merge($data, $this->CI->load->_ci_cached_vars);

    This should do the trick.

  56. I think I just commented out that line which seemed to work. Not ideal though.
    But replacing it with that piece of code did the trick.


  57. matt says:

    Hi there,

    Loving smarty + CI but having problems when csrf protection is enabled.

    The form_open helper function doesn’t add the hidden field (obviously I’ve testing by turning on php tags)

    appears if I just load the view using the build in CI parser but doesn’t appear if I swtich batch to the smarty parser.

    Anyone go any ideas on how to get round this?


  58. matt says:

    Ignore that – stupidly had left cache on!
    What a moron!

  59. Jason says:

    How do i use validation_errors ?

  60. nlefebvre says:

    assigneton how a model ?

  61. ji zhang says:

    the property of $_ci_cached_vars of Loader class is protected , as result

    $this->CI->load->_ci_cached_vars will throw error.

    suggest change the that property to public

  62. Pedma says:


    Nice scripts & tutorial. Thanks. Is it possible to use it for Modular CI (HMVC ) ?
    If yes, How ?


  63. Pedma says:


    I think we can use it for HMVC modular, IF it’s possible to add another “template_directory” to …/config/smarty.php file.
    Maybe as an array ?

    If I just add like this :
    $config[‘template_directory’] = APPPATH.”modules/smartytest/views/”;
    $config[‘template_directory’] = APPPATH.”modules/mytest/views/”;

    Smarty will call only the last one .. πŸ™

    Any idea ?


  64. lefebvre says:

    the cache does not work.
    it is not on file cache

  65. Dwayne says:

    What do you mean?

  66. Troy says:

    I cannot get the template to produce anything, it just produces a white page. Any ideas?

  67. lilwanna says:

    hi ! great job !
    i have a problem, with sub folder i can’t parse anything
    i modifies the config : $config[‘template_directory’] = APPPATH.”views/admin/”;
    but i have a white page

    In the parse() function (my_parser) in line 36
    foreach ($data as $key => $val)
    //echo “$key : $val “;
    $this->CI->smarty->assign($key, $val);

    my echo give me the key and the value but i have nothing in my view

    any idea ?

  68. Ian says:

    @Troy, ensure the directories under application/cache/smarty are writeable by the web server (www-data on Debian, for example). This is a Smarty requirement but isn’t mentioned here in the setup instructions, it caused the same problem for me for a while.

  69. Troy says:

    @Ian, thanks that was the problem.

  70. Loc Dinh says:

    Hi Dwayne,

    Your code is fantastic however it does not work with Smarty 3.1, i tried to integrate it with CodeIgniter 2.0.3 however this happened:
    Message: Undefined property: CI_Smarty::$template_ext
    Filename: Smarty/Smarty.class.php
    Line Number: 628

    Message: Undefined property: CI_Smarty::$exception_handler
    Filename: Smarty/Smarty.class.php
    Line Number: 628

    Do you have a plan to look at the latest Smarty version ? Any direction to fix this will be very appreciated.



  71. Dwayne says:

    Hey Loc,

    I plan on bringing it up to scratch for the latest version of Smarty within the next week or so. Looks like 3.1 of Smarty changed a few things in relation to how things are set.

  72. Laurence says:

    Hi Dwayne,
    I’m using the library, and it seems to be working well, but one thing I noticed is that I have to refresh a page “twice” to see any changes I make to my code (when I use your parser).

    I’ve got cache disabled from what I can tell – any ideas why this is happening?


  73. Laurence says:

    never mind – worked it out – it was a flash issue

  74. Christian says:

    when i try to use a ci helper like base_url() or site_url() in the views ci gives a blank page..
    Example: {site_url(‘smartytest’)}.
    Anybody knows why this doesnt work ?

  75. DarkStar says:

    @Christian :

    it’s totaly normal : you have disabled the error_reporting (or “display_errors is Off”). If it was enabled you have had an error.

    … and it’s still normal ! You try to use a PHP function into Smarty. It’s possible but not like that ! Smarty is ONLY using keywords & vars.

    To use a custom function from PHP into smarty, use it like that :
    {php}echo site_url(‘smartytest’);{/php}

  76. Patrick says:

    Hmm when I load the class nothing happends it stops suddenly at this line:
    $template_string = $this->CI->smarty->fetch($template);

    in; MY_parser.php

    anybody help :x?
    love to use smarty with my CI πŸ™‚

  77. Tigran says:

    The same problem. Please help!!!


  78. DarkStar says:

    You should use the parser… and even with using Smarty you should use “display()”.

    This is how I use it :
    /* ASSIGN & OUTPUT */
    $this->parser->parse(‘extends:_canvas_template_public.html|view_’ . basename(__FILE__, ‘.php’) . ‘.html’, $data);

    But for a single template file, you can use :

  79. Tigran says:

    Thanks a lot for response.
    I set the “owner” of my “cache” folder to “nobody” and everything worked perfectly.


  80. Patrick says:

    how can yet set the owner to nobody?

  81. DarkStar says:

    I suppose it is the “chown” command.

    chown [-hHLPR] [user][:group] target1 [target2 ..]

    chown -R nobody:nobody /path/to/your/site

  82. Dwayne says:

    I’ve recently made some updates guys to this library which should sort out some issues. As DarkStar pointed out earlier, use $this->parser->parse() to parse templates and not the library directly.

    As for cache file issues, if you don’t have access to change owners of folders like some shared hosts disallow, changing the permissions via your FTP client on the cache folders to 757 (using CHMOD) will most likely fix it too.

  83. Patrick says:

    How stupid I was, my problem was that my cache folder wasnt writeable after I changed that, it was fixxed :D! πŸ™‚

  84. Thyagi says:

    nice, but have a cache issue, on smarty.pgp config
    $config[‘cache_status’] = 1 need to be TRUE.
    With 1 he only put cache on compiled folder, not in cached folder..

  85. Varun says:

    I installed the latest stable release of smart 3.1.11 and I am getting this error

    A PHP Error was encountered

    Severity: User Notice

    Message: Undefined property: CI_Smarty::$template_ext

    Filename: Smarty/Smarty.class.php

    Line Number: 697

    Someone please help it’s urgent

  86. Dwayne says:


    Did you by any chance change the error reporting value in the smarty.php config file?

    Does your config value look like this:

    $config[‘template_error_reporting’] = E_ALL & ~E_NOTICE;

    Located in your application/config/smarty.php file – the above should stop all user notices from appearing. Although not the best solution it will solve the problem you’re having. That isn’t an error, just a notice message which won’t stop the page loading.

  87. Uziel says:

    Hi, this is a awesome aport. I’m using this.

    I wanna to use the tag php ( {php} echo “hola”; {/php} ei. ), but I get a error from smarty. How I can use the tag php?


  88. DarkStar says:

    First, you SHOULD NOT use the {php} tag… it’s a security failure…

    Anyway, just a little search on Google gives you the answer : init Smarty with SmartyBC.class.php instead of Smarty.class.php

    // include(‘Smarty.class.php’);

  89. lalo says:

    Hi there,

    I updated the folders, and the page renders, but I lost all the |cat:$lang|cat: I had placed in my template, that works as a relative path depending on what language the user has selected…

    how can I fix that?

  90. uilson says:

    Hi Dwayne, I’m using your Ci-Smarty templating engine, but i can’t get it to work with the, for some reason it loads the first page (the function index()) just fine, but it wont load the other pages, it simply shows the 404 page.

    Using the url ‘http://localhost/tvicarus/en/’ it loads the index page but if i select other page like ‘http://localhost/tvicarus/en/guide’ it justs show the 404 page.

    But if i change the index page to other one it loads.
    For example:

    public function index() {
    } #index

    it loads the news as first page, if I change to other page, like

    public function index() {
    } #index

    it loads the guide, as first page, without any problem.

    Can you help me and try to make it work?

    Thank you.

  91. HMVC + smarty 2.x also works well
    There are also problems 3.x

    you help?

  92. Aditya says:

    I am using your library , but the tags are getting printed as it is.
    “{include file=”header.tpl” title=”Equippoint | Home” name=$Name} ”

    Code Snippets
    public function index(){
    $data = array();
    $this->parser->parse(‘home.tpl’, $data);

Leave a Reply

Your email address will not be published. Required fields are marked *