Welcome Guest, Not a member yet? Register   Sign In
Can I use system variables or functions if using view parser
#6

For completeness, I'll follow up with how I found adding a fuller featured template engine.

After a bit of reading, it seemed like Smarty was gonna suit me best, so grabbed that and its Codeigniter integration code (Smartie altho the way it is loaded in the autoloader makes the latter invisible). Overall pretty painless. Redoing the Codeigniter News tutorial, essentially the changes were:

Code:
$this->load->view('x', $data);
to:
$this->smarty->view('x.tpl', $data);

<php? echo $x ?> to {$x}
<php? echo $var['x'] ?> to {$var.x}
<php? foreach ... ?> to {foreach ...}

<php? echo base_url(); ?> to {base_url()}

So my news/create view then looked like:

Code:
<h2>{$title}</h2>
 
{validation_errors()}

<form method="post" action="{base_url()}news/create">

   <label for="title">Title</label>
   <input type="input" name="title" /><br />

   <label for="text">Text</label>
   <textarea name="text"></textarea><br />

   <input type="submit" name="submit" value="Create news item" />

</form>

So finally, thanks for you help and suggestions.

regards
Mark
Reply


Messages In This Thread
RE: Can I use system variables or functions if using view parser - by markir - 04-29-2019, 10:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB