Smarty in Lithium php framework

Download the plugin here.

https://github.com/alexdenvir/li3_smarty

Add it to your Lithium based project

lithium_project_root/
  |___ app
  |     |__ config
  |            |__ bootstrap
  |                    |__ libraries.php      => edit this to add smarty plugin
  |     
  |     |__ controllers
  |            |__ PagesController.php
  |     
  |     ...
  |     |__ resources
  |            |__ template_c        => smarty compiled templates will be put here
  |
  |     |__ views
  |            |__ pages
  |                  |__ index.html.tpl
  |
  |___ libraries
  |     |__ li3_smarty               => put the smarty plugin files here
  |     ...

Activate the plugin

Add to the end of libraries.php

/**
 * Smarty template engine
 **/
Libraries::add('li3_smarty', array());

Use it
Create template app/views/pages/index.html.tpl

I want to display my {$var}

Add controller app/controller/PagesController.php

public function index() {
        $var = "test variable!";
        $this->set(compact('var'));
}

Feel it
Perfect! http://localhost/pages

I want to display my test variable!
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s