Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

akuzemchak/smartyview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smartyview

A ridiculously simple Smarty 3 Spark for CodeIgniter 2

Wait! Before You Continue...

This project is no longer maintained, and will receive no updates or support. Use at your own discretion.

Installation

  1. Get Sparks.
  2. In a terminal, cd to your project root and type php tools/spark install smartyview.
  3. Create the necessary folders in the locations specified in the Smartyview config file.
  4. Add Smartyview to your Sparks autoload array:
    $autoload['sparks'] = array('smartyview/x.x.x');
    Or, load it manually in your controllers/models/whatever:
    $this->load->spark('smartyview/x.x.x');
    Please remember to use the real version number of the Spark you installed!

Rendering Templates

First, you need to create your data array, just like you would for "normal" views.

$data = array(
    'title' => 'My Page',
    'subtitle' => 'My Subtitle',
    'etc' => '...'
);

Normally at this point, you would use $this->load->view('viewfile', $data) to output your content, but to render a Smarty template, you will do this instead:

$this->smartyview->render('my-template.tpl', $data);

By default, your template files will be stored in your application/views/ directory, and should be named with either a .tpl or .php extension. You can change the templates directory in the Smartyview config file.

That's it!

Need Help Using Smarty?

They have great docs... check them out.

Other Noteworthy Items

In your templates, you should be able to call any CodeIgniter functions, as long as they are enclosed in curly braces:

{anchor('pages/test', 'Test Page')}

However, if you are calling any CodeIgniter objects using the $this keyword, you will need to use $CI instead:

{$CI->uri->uri_string()}

About

Smarty 3 Spark for CodeIgniter 2

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages