0

i am trying to create a widgetized contents.. basically i want to have blocks in my layout that gets populated from different module/controller/actions ...

i tried using $this->action in view but it seems that action has been removed in ZF2 (or not ?) service manager cant find it :

Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for action

i also tried forward action helper inside a module's 'Zend\Mvc\Application::dispatch' event but can't call forward becuase there is no controller ????

so how can i load blocks(different module/controller/actions) in my layout ???

Exlord
  • 5,009
  • 4
  • 31
  • 51
  • 1
    Please see http://www.michaelgallego.fr/blog/2012/10/06/how-to-replace-the-action-helper-in-zf-2-and-make-great-widgetized-content/ This is all i can suggest on that topic without specific code problems – Sam Dec 05 '12 at 13:10
  • you should also check that the url pass in the action in also map in `module.config.php` file. This error also occur due to that. – Code Lღver Mar 19 '13 at 11:54

1 Answers1

0

Ok here is what i did:

  • Created a view helper for each block
  • created a index in module config file to hold a list of blockable view helpers
  • created a table to hold the list of blocks and their configurations
  • created a "new block action" witch load the list of blockable helpers
    • user picks a helper type and gets redirected to the other page
    • here helper specific configs are loaded
      • the form in this page firs a event to collect helper config
      • modules can handle this event and create the config fieldset and give it to the form
    • i also load a list of block positions from my templates ini config file
  • created a "blocks" view helper witch accepts one parameter "block position" and then searches the blocks table for a match for that position
    • if any found : each items associated view helper is executed and the outputs are collected and returned to the view
Exlord
  • 5,009
  • 4
  • 31
  • 51