Welcome Guest, Not a member yet? Register   Sign In
Execute controller from view
#15

[eluser]esra[/eluser]
[quote author="abmcr" date="1193948361"]A question similar: it is possible to call a function of a controller into a function of another controller? For example


function temp(){
?????? how to
$data=$this->function_of_another_controller($parameters);

Thank You[/quote]

The above is possible with the Modular Separation extensions by Zacharias.

Many are handling the multiple controller issue using view fragments which have a dedicated helper. The controller and model code reside in the helper. The helper is loaded in a base controller and all other controllers are extended from the base controller. The view fragments which are loaded by the controller call the helper functions as needed. To access data from a helper, you need to create an instance of the CI super object. Note that this issue is a MVC 2 (Sun Model 2) problem and not a SmallTalk MVC (MVC 1) problem. For anyone who wants to do this, Coolfactor's proposed View library for CodeIgniter is a good solution for loading multiple view fragments in a master view (template). Note this this solution results in poor encapsulation. There are numerous threads on the forums discussing the problem with few solutions.

Someone above mentioned that the controller was not a mediator which is true. There are two popular architectural design patterns for handling nested controllers--PAC (Presentation-Abstraction-Control and HMVC (Hierarchial-Model-View-Controller). PAC uses the Mediator design pattern to control any number of nested controllers. HMVC uses the Chain of Responsibility design pattern to nest any number of controllers. These patterns are popular in the Java world. The only implementation of a framework based on HMVC for PHP is the abandoned Claw framework (available on Tigris or phpclasses.org). I have yet to see an open source version of a PAC based framework for PHP. Both PAC and HMVC result in much better encapsulation than MVC.


Messages In This Thread
Execute controller from view - by El Forum - 11-01-2007, 03:23 AM
Execute controller from view - by El Forum - 11-01-2007, 04:12 AM
Execute controller from view - by El Forum - 11-01-2007, 04:48 AM
Execute controller from view - by El Forum - 11-01-2007, 05:07 AM
Execute controller from view - by El Forum - 11-01-2007, 05:17 AM
Execute controller from view - by El Forum - 11-01-2007, 05:34 AM
Execute controller from view - by El Forum - 11-01-2007, 06:01 AM
Execute controller from view - by El Forum - 11-01-2007, 07:37 AM
Execute controller from view - by El Forum - 11-01-2007, 09:19 AM
Execute controller from view - by El Forum - 11-01-2007, 10:14 AM
Execute controller from view - by El Forum - 11-01-2007, 04:25 PM
Execute controller from view - by El Forum - 11-01-2007, 04:47 PM
Execute controller from view - by El Forum - 11-02-2007, 08:20 AM
Execute controller from view - by El Forum - 11-02-2007, 11:17 AM
Execute controller from view - by El Forum - 11-02-2007, 02:38 PM
Execute controller from view - by El Forum - 07-07-2009, 10:33 AM
Execute controller from view - by El Forum - 07-07-2009, 12:26 PM
Execute controller from view - by El Forum - 02-17-2010, 07:29 AM
Execute controller from view - by El Forum - 07-27-2011, 06:35 AM
Execute controller from view - by El Forum - 07-27-2011, 08:07 AM
Execute controller from view - by El Forum - 07-27-2011, 08:37 AM
Execute controller from view - by El Forum - 08-03-2011, 02:20 AM
Execute controller from view - by El Forum - 08-06-2011, 03:04 AM
Execute controller from view - by El Forum - 08-06-2011, 05:24 PM
Execute controller from view - by El Forum - 08-08-2011, 04:09 AM
Execute controller from view - by El Forum - 08-09-2011, 02:59 AM
Execute controller from view - by El Forum - 07-18-2012, 06:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB