Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Using Parser Twig in Theme
  • Dear,

    I have added Parser Twig using Composer. and added 'parser' packages in always load section. commented out always load section.

    Now i need to use twig in Theme.

    In theme default config, i have added .php as extension.

    i have changed one of my partial to .twig extension, so error coming up saying that "partial not found.

    if have changed .php extension in default theme config. will php work with .twig extension?

    i need to use twig in some partials.

    if i can use twig, how i use it, any change in Controller needed?
  • HarroHarro
    Accepted Answer
    If you have installed the Twig and the parser package, you only need to specify the extension.

    View::forge('viewname'); // will load the viewname.php view file if view_ext was set to '.php'
    View::forge('viewname.twig'); // will load the viewname.twig view file through the Twig engine

    So the config only defines the default, for when you use view names without specifying the extension.

    If you use multiple template systems at the same time (like both php and twig templates), you need to decide with one will be your default, and you have to hardcode the type for the other.

    You can not dynamically switch from one type to the other on a per-file basis, without changing your code.

Howdy, Stranger!

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

In this Discussion