Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li>Put Smarty to CI in some folder, for example, third_party/smarty.</li> <li>Add Smarty to CI - create library application/libraries/Mysmarty.php</li> </ol> <p>define('SMARTY_DIR', APPPATH . 'third_party/smarty/'); require_once(SMARTY_DIR.'Smarty.class.php');</p> <pre><code>class Mysmarty extends Smarty { public function __construct ( ) { parent::__construct(); $config =&amp; get_config(); $this-&gt;template_dir = $config['smarty_template_dir']; $this-&gt;compile_dir = $config['smarty_compile_dir']; $this-&gt;cache_dir = $config['cache_dir']; $this-&gt;caching = $config['caching']; } function view($resource_name, $params = array()) { if (strpos($resource_name, '.') === false) { $resource_name .= '.tpl'; } if (is_array($params) &amp;&amp; count($params)) { foreach ($params as $key =&gt; $value) { $this-&gt;assign($key, $value); } } if (!is_file($this-&gt;template_dir . $resource_name)) { show_error("template: [$resource_name] cannot be found."); } return parent::display($resource_name); } } </code></pre> <ol> <li><p>Add new config variables to application/config/config.php</p> <p>$config['smarty_template_dir'] = APPPATH . 'views/'; // folder for your smarty templates $config['smarty_compile_dir'] = APPPATH . 'cache/smarty/compiled/'; // create this folder $config['cache_dir'] = APPPATH . 'cache/smarty/cached/'; // create this folder $config['caching'] = 0;</p></li> <li><p>Add new library to autoload in file application/config/autoload.php </p> <p>$autoload['libraries'] = array('database', 'session', 'mysmarty');</p></li> <li><p>Now in your controller try to add some variable to smarty:</p> <p>$this->mysmarty->assign('url', $this->config->item('base_url'));</p></li> </ol> <p>and then show your template:</p> <pre><code>$this-&gt;mysmarty-&gt;view('main'); // template path is application/views/main.tpl </code></pre> <p>And in main.tpl add your form</p> <pre><code>&lt;form action={$url} method="post" id="login_form"&gt; ... enter code here </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload