Skip to content

tigerduck42/cakephp-smarty-view

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

CakePHP 3 Smarty View

Install Smarty

Manual

Download Smarty from here Extract it to app/vendor/smarty

With composer (required)

composer require smarty/smarty

Install Smarty View

Copy the SmartyView.php file from src > View folder to your View folder.

Include in AppController.php

Load SmartyView in your CakePhp project like in AppConroller.php file or below:

namespace App\Controller;

use Cake\Controller\Controller;
use Cake\Event\Event;

class AppController extends Controller
{
    // Your code
    public function beforeRender(Event $event)
    {
        $this->viewBuilder()->className('Smarty'); // SET SMARTY VIEW
    }
    // Your code
}

Rename templates

Rename all template files with .ctp extension in .tpl extension.

IMPORTANT: You can rename all, not just the templates and include all with Smarty include {include file="_file_.tpl"} syntax.

Include in layouts

{$this->fetch('content')}

Enjoy ;)

About

CakePHP 3 Smarty View

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%