Question

A while ago I followed the tutorial and included the TemplatePathStack like it is described here.

The tutorial suggests for the view directory a structure like view/album/album in which all the phtml-files lie.

I wonder what's the reason for album/album... And what if my module is named MasterData and it included add/edit/delete... for Entity1 and Entity2.

How does the framework know which add.phtml to use?

Was it helpful?

Solution

I'm wondering if you're not confusing the entities with the controllers. Make sure you're following the module directory structure conventions that is summarized (including only what is relevant to your question) as follows:

/module
|--/MasterData
|----/src
|--------/Controller
|-----------/Entity1Controller
|-----------/Entity2Controller
|--------/Model
|-----------/Entity1
|-----------/Entity2
|----/view
|------/master-data
|--------/entity1
|-----------/action1.phtml
|-----------/action2.phtml
|--------/entity2
|-----------/action1.phtml
|-----------/action2.phtml
...

For the template path stack, and under the previous structure, the configuration is simply:

'view_manager' => array(
      'template_path_stack' => array(
           __DIR__ . '/../view',
       ),
),

Remember, under the view folder the default convention:

  • entity1 is mapped to your Entity1Controller (in case your controller is camelCased, eg: MyFooController, the corresponding folder name would be my-foo)
  • action1.phtml is mapped to the action1Action method of your Entity1Controller class (same remark as above if your action name is camelcased).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top