I am using CakePHP 2.4.2 and this plugin by predominant.
I want to use TwigView with CakePHP and found that the plugin above is compatible with CakePHP 2.0. Followed all the installation steps, however, getting the Missing View error while executing the script.
My AppController.php
<?php
App::uses('Controller', 'Controller');
class AppController extends Controller {
public $viewClass = 'TwigView.Twig';
}
The view's extention is .tpl, however, even after adding the Plugin it is still looking for .ctp extention.
I have also loaded the plugin in bootstrap.php using
CakePlugin::load('TwigView');
define('TWIG_VIEW_CACHE', APP . 'tmp');
Any Idea what could go wrong.
http://api.cakephp.org/2.4/source-class-Controller.html#209-214
Set the Controller::$ext property in your app controller to "tpl" and your're done.
Searching before asking is also always a good idea, see CakePHP View change extension
Related
Iam trying to switch to hmvc in codeigniter. I will explain my issue from scratch itself. First I downloaded Codeignter 3.0 version from http://www.codeigniter.com/download and when I check my browser it is showing the welcome message of CI. Now to add hmvc structure I downloaded the hmvc modular extension from https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/downloads. And placed the core and third party modules inside my CI folder. Then I created a Folder inside the application folder and named it as modules. Within modules I created a folder say test. I have a controller folder which contain test.php.
class Test extends MY_Controller {
public function index()
{
echo "hey my first module is ready";
}
}
But when i call the module in the url like localhost/index.php/test i got a page not found error. Am i missing any configuration? I got all other controller working well before i switched to hmvc. How can i fix this. Thanks in advance.
Do you forget this piece of code in your config file?
$config['modules_locations'] = array(
APPPATH.'modules/' => '../modules/',
);
Do you created your own Controller? Cause you extends MY_Controller.
If not, extend CI_Controller or MX_Controller
For more information read the documentation at wiredesignz's HMVC for Codeigniter
Kind regards
Try to follow this tutorial.Here you will get ready to use HMVC folder. http://www.darwinbiler.com/ready-to-use-codeigniter-modular-extensions-hmvc/
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?
I want to parse a PDF document in my project, I'm using Yii framework and I'm able to load ZendFramework 1.12, actually I'm using Zend_Lucene and Zend_Mail successfully, but ZendPdf fails to parse the PDF, so I wanted to try with ZF2 (ZendFramework 2), but I'm not able to make it work... I just downloaded the ZF2 library and added the following to my base Controller:
public function __construct($id,$module=null){
Yii::import('application.vendors.ZendFramework.library.*');
Yii::setPathOfAlias('Zend',Yii::getPathOfAlias('application.vendors.ZendFramework.library.Zend'));
parent::__construct($id,$module);
}
So every time I use a Controller this code is executed. Then in the controller I have:
use ZendPdf\PdfDocument;
use Zend\Mail;
class AjaxController extends Controller{...
...
public function actionTestPdf(){
$filepath = realpath('./path/').'/pdftest2.pdf';
$pdf = PdfDocument::load($filepath);
}
When I run the controller: /ajax/TestPdf
I get: Fatal error: Class 'ZendPdf\PdfDocument' not found
What am I doing wrong?
I'd suggest you to install your ZF2 stuff with composer and include the autoloader from composer to get PSR compatible autoloading.
Alternative 1)
You may also try pointing an alias ZendPdf\PdfDocument to the class file location.
Alternative 2)
import the needed classes or directories in your application config.
In this particular case I would recommend NOT using ZendPdf from ZF2, because it is functionally equivalent to Zend_Pdf from ZF1 and so all you're going to do is add unnecessary complexity with classloading, etc, but not solve your underlying problem, as the document will still most likely NOT load using ZendPdf from ZF2.
You should investigate the underlying reason why the document is failing to load in ZF1.
I am new to CakePHP, but I've started using CakePHP 2.0. Unfortunately my host has PHP 5.2.6 and CakePHP 2 won't run. I want to add a Facebook plugin to my CakePHP 1.3 application. I downloaded the plugin into the app\plugins\facebook folder and copied facebook.php from app\plugins\facebook\config\facebook.php to app\config\facebook.php
class AppController extends AppController {
var $helpers = array('Facebook.Facebook');
}
It is reporting missing facebook helper app\views\helpers\facebook.php
<?php CakePlugin::load('Facebook'); ?> //in bootstrap.php is giving an error
Is there anything I would have done in bootstrap.php to cause this and how might I fix it?
All you need to do Enable the plugin in app/Config/bootstrap.php , You also need to add your appID and AppSecret.
For Details you can see the configuration in following link
https://github.com/Pollenizer/CakePHP-Facebook-Plugin
Hope it works for you.
I'm trying out codeIgniter and the Modular Extension. So far I followed the installation instructions from wiredesignz on bitbucket. Now I'm trying the tutorial HMVC: an Introduction and Application from NetTuts.
I'm doing this with the actual version of CodeIgniter 2.1 and the actual version of the Modular Extension (downloaded the .zip version from bitbucket).
All works fine until I'm trying to run a method from a controller of another module.
The setup in short is, that there's two modules (site & login). Within the site's controllers there's site.php (/modules/site/controllers/site.php) with a method that checks if a user is logged in. This method would exit the script execution if accessing the site without being logged in. As this method logically belongs to the login module, the author suggests moving it there. So it then is moved to /modules/login/controllers/login.php.
The problem now is, how to access the method of the login module from within the site module. The slightly adjusted code from the tutorial:
// modules/site/controllers/site.php
function __construct()
{
// parent::Controller();
// replaced with:
parent::__construct();
// modules::run('login/is_logged_in');
// replaces with:
$this->load->module('login')->is_logged_in();
}
Like this I'm getting an error:
Unable to load the requested file: logged_in_area.php
The method in question is inside the site module as well:
// modules/site/controllers/site.php
function members_area()
{
$this->load->view('logged_in_area');
}
The Script executes right until the load->view line and produces the error. There's no problem accessing the logged_in_area.php with running the is_logged_in method from within the site controller with the line:
$this->is_logged_in();
Any ideas?
edit:
the application tree:
/application
/...
/modules
/login
/controllers
login.php
/models
/views
login_form.php
signup_form.php
signup_successful.php
/site
/controllers
site.php
/models
membership_model.php
/views
logged_in_area.php
PS: How can I get more INformation about the error? CodeIgniter seems to be very reserved about error output ...
As stated in the documentation here to load a view from within another module, you need to use an extended MX controller and a method:
<?php echo Modules::run('module/controller/method', $param, $...); ?>