Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Problem with implements SMARTY
  • Hello, firt I´m sorry for me English.
    I have a little problem with implements SMARTY template system into fuel.
    I set up autoloader parse class in cofing, at once I download SMARTY from offcicial site and copy files to fuel/app/vedor/Smarty i copy Parser.php to fuel/app/config/ and edit it to: 'extensions' => array(
    'php' => 'View',
    'twig' => 'View_Twig',
    'mustache' => 'View_Mustache',
    'md' => 'View_Markdown',
    'dwoo' => 'View_Dwoo', // array('class' => 'View_Dwoo', 'extension' => 'tpl'),
    'jade' => 'View_Jade',
    'haml' => 'View_Haml',
    'smarty' => array('class' => 'View_Smarty', 'extension' => 'tpl'),
    ),
    At last i my controller I call view this way: public function action_index()
    { return Response::forge(View_Smarty::forge('welcome/debug'));
    }
    But it doesn´t work. Show me error:
    Fuel\Core\FuelException [ Error ]: The requested view could not be found: welcome/debug
    In folder with views I have debug.tpl
    Plase help me
  • The parser doesn't work that way. It extends the View class to support parsers, and uses the defined extension to determine which parser to load. So your method should be:
    public function action_index()
    {
        return Response::forge(View::forge('welcome/debug.tpl'));
    }
    
  • Almost, the key in the 'extensions' config array is the expected extension. Thus unless you change that, the correct code should be:
    public function action_index()
    {
        return Response::forge(View::forge('welcome/debug.smarty'));
    }
    

    'smarty' => array('class' => 'View_Smarty', 'extension' => 'tpl'),
    The value given with 'extension' allows you to expect another extension in the filename than you use in the code. In this case you'd use the code above but the file would be in app/views/welcome/debug.tpl (to keep with the lib's own convention and allow for color coding in IDEs)
  • It works, thank you very much :), I start with programing in this framework but there are alot of templating systems choice.
    What templating system would you recommanded to me ?
  • I've become a big fan of Twig, it's incredibly fast for a templating engine (actually faster than Mustache to my astonishment) and very powerfull.
  • I check it and it seems that twig is tempate system of symphony framework. Unfortunately FuelPHP , doesn´t have any documentation how to work with Twig.... :/ ..
    For example how Can I create form with action with Twig ? edit: I have antoher question, it is possible tu create SNIPPET blocks like it is in Nette php framewok ? When you use ajax ...
  • I am trying to follow the steps here to use smarty templates but its not working. How do I edit the defaut depot homepage controller with before, after, 404 and index methods? Where do I store the templates - in 'app/views' or in 'themes/default/templates'? 
  • Depot uses the Theme class, it doesn't load views directly. So all views are in the themes folder, not in app/views.

    If the parser package is loaded, and you've installed Smarty, the Theme class should be able to work with Smarty templates without problems.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion