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

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

1
2
3
4
5
6
7
<?php
App::import('Controller', 'Products');
$productObj = new ProductsController;
---
---
$productimage = $productObj->getProductImage($productId);
?>

We can use this way also.

Categories: CakePHPFramework

1 Comment

Shasi Kanth Dulipalla · January 4, 2017 at 4:13 pm

Very useful example… thanks for sharing!

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *