1

I have two modules called 'image manager' and 'add products'. I want to include all image manager view inside a div in products module .

someone please help me,

Regards,

Lanka

1
  • could you take a look at my answers? Commented Jan 23, 2014 at 19:47

3 Answers 3

1

You can execute a controller action from within another controller action using the forward() plugin, where you can then add the response (ViewModel) as a child view.

The main benefit of this is that you reuse and keep the controller logic encapsulated for each 'view'. This allows the build up a widget like views without coupling/duplicating code.

For example

class ProductsController extends AbstractActionController { public function viewProductAction() { //... View product controller logic // // $view = new ViewModel(array('foo', 'bar')); // Dispatch the controller to view images for this 'product_id' $viewManagerView = $this->forward()->dispatch('ImageManager\Controller\ViewImageController', array( 'action' => 'view-images', 'product_id' => $product->getId(), )); // Attach the child view to the main view if ($viewManagerView instanceof ViewModel) { $view->addChild($viewManagerView, 'productImages'); } return $view; } 

}

An then within a products-module/products/view-product.phtml render the child view

echo $this->productImages; 

You can read more about the forward plugin in the documentation

Sign up to request clarification or add additional context in comments.

Comments

0

Reading your comments, i see that it is not a ZF2 error, and probably not even a third party module, so it could be an ElFinder Error. Probably it cannot find some required resources.

Reading some code and some webdites, i think that probably you are just lacking the url option of the viewhelper, so ElFinder can find the backend route he tries to connect to.

With the QuElFinder, the route to the connector is /quelfinder/connector so in your view, the code will be:

echo $this->QuElFinder('elfinder', array( 'width' => "50%", 'height' => '300', 'url' => '/quelfinder/connector' ) ); 

Also, you should go to QuElFinder/config/module.config.php and check everything under

 'QuConfig'=>array( 'QuElFinder'=>array( 

because as you can see in the QuElFinder controller, in the connectorAction() function, it is reading that configuration, and there is a lot of paths.

Comments

0

This kind of scenario sounds typical for a ViewHelper. Though it requires application logic, too. You'd need to have some way of gluing Products and Images together.

Since it's two separate Modules you'd probably extend the ProductForm and inject a new Element into the Form so that the User could choose the images he want to glue to the Product. This would usually be a 1-N Relationship since one Product can have many Images but one Image should only belong to one Product.

If you need more help than that, then you need to start coding and come back with real questions :)

3 Comments

I'm using zend framework 2 with elfinder and it's working fine (inside elfinder view). I have module named options , the problem is when i'm using that elfinder helper inside options view it gave me error called "Unable to connect to backend. Backend not found." this is the code i'm using inside options view echo $this->QuElFinder( 'elfinder', array( 'width' => "50%", 'height' => "300", )); Please someone help me, Thanks Lanka
@pandukhabaya I have no clue about elFinder, all I know is that people have lots of problems with it. Just ask the elFinder Team/Guy on GitHub
i guess you are using the QuElFinder module from Celtico, right? that error message is not anywhere in the code of QuElFinder, you should follow the code to see where it is crashing. Probaly is something with ElFinder, or with QuElFinder, or with your code

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.