Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Use Twig with Theme class instance
  • Hi,

    How it's possible to use Twig with Fuel Theme class instance ?

    I specially want to use Twig templace iheritance : http://twig.sensiolabs.org/doc/templates.html#template-inheritance
  • If you use Twig via the Parser package, it works transparently for everything that uses views.

    I'm not a Twig user, so I can't comment on specific functionality, but I can imagine this might be an issue, since Twig internal logic is used to load templates, and not Fuel. Twig obviously is not aware of how Fuel operates and where view files should be loaded from.
  • Thanks for your answere, I've found a solution. It's work, but i don't know if is a good practise :

    In my base controller i set the template with :
            \Theme::instance()->set_template("layout.twig");

    The layout.twig template contains a twig block like :
            {% block content %} Here is the layout <br/> {% endblock %}

    In my controller, i want to return a view which extends the block "content" :
            return \Theme::instance()->view('frontend/home/index.twig');

    My frontend/home/index.twig :
            {% extends "templates/default/layout.twig" %}
            {% block content %}
            {{ parent() }}
            Here is the view Index
            {% endblock %}

  • It that works, I don't see why not.

Howdy, Stranger!

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

In this Discussion