They’ll be a few obscure corner case blog posts incoming for CodeIgniter that I’ve encountered over the past few months.

PHP’s CodeIgniter framework offers two directories for your project:

  • /app for the base code that may be shared by many projects
  • /assets for customised content used only by one project, such as CSS, images, and layout templates.

With Smarty templating engine, I encountered issues when using {include} from /assets that would make use of subviews in /app. You need to use the absolute path of your templates_c directory to relatively reference the /app view.


  • /app/modules/shop/views/footer.php
  • /assets/templates/shop/view.php

From view.php, I want to Smarty include footer.php. Considering my generated Smarty files are located in /assets/templates_c (your location may be setup differently), the two lines I would use in view.php are:

{assign var=path value=dirname($smarty.const.__FILE__)}
{include file="$path/../../app/modules/shop/views/footer.php"}

Keep in mind for an include within an include, if your /app view also uses an {include}, Smarty will fail since the path isn’t relative to the /assets view.