0

I'm new to CakePHP and I need to integrate Twig for a project. First I installed the TwigView plugin (https://github.com/predominant/TwigView) and tried to follow the small set of instructions.

Installation

Plugin sources

I cloned the plugin repository in /app/Plugin/. A folder TwigView is created.

Twig sources

I placed Twig sources under /app/Plugin/TwigView/Vendor/ in a folder named Twig

Configuration

I added this to my /app/Config/bootstrap.php

CakePlugin::loadAll();

and this to AppController

public $viewClass = 'TwigView.Twig';

I also granted write privileges to everybody in /app/Plugin/TwigView/tmp/views

Problem 1

The application keeps asking for .ctp files, and I need to use my .tpl templates. I tried adding this in AppController

public $layout = 'default.tpl';

But it will complain, saying that it can't find default.tpl.ctp

Problem 2

How can I pass parameters to the twig templates from Cake controllers?

2
  • If it's still searching for .ctp files, then TwigView isn't being set. The Twig view class sets the extensions to .tpl for you, so no need to change the $layout var. More info required to answer. I.e., ensure the plugin is running, make sure it's using the view class, etc. Pepper some debug statements in the plugin and your bootstrap to make sure everything's running right. Show us a basic controller / action that should be using it and make sure the view class isn't being reset somewhere. Commented Aug 6, 2014 at 23:07
  • 1
    Also, see: stackoverflow.com/questions/20138038/… Commented Aug 6, 2014 at 23:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.