How to call controller’s method within the view in CakePHP

in CakePHP, Framework / 1 Comment

Hi friends, In the older posts we learned about CakePHP. In this post, I would like to explain about how to call controller’s method within the view in CakePHP. This is a very simple post but it may use in few issues.

How to call controller's method within the view in CakePHP by Anil Kumar Panigrahi

How to call controller’s method within the view in CakePHP by Anil Kumar Panigrahi


Assume below the controllers and method.
Controller: Products, Orders
View: OrderDetails

Call the Products controller method in OrderDetails

<?php
App::import('Controller', 'Products');
$productObj = new ProductsController;
---
---
$productimage = $productObj->getProductImage($productId);
?>

We can use this way also.

With more than 9 years experience in PHP and Founder of Anil Labs, a blog for PHP and related posts. contributed posts regarding CodeIgniter, CakePHP and Learn PHP online ... Contact : php.anil@gmail.com

Discussion 1 Comment

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>