php - what i need for invoke various actions and view in my layour main

441

well i trying build a website on ZendFrameWork 2 i want execute various actions in my layout main like a fild of search, or a form for loguin etc. each one of this i believe should are in views diferents with your actions, how i do for references this actions with your views that will return this element for i put where i want in my layout. like the helper $this->content; where it return the context view and action no just the view with no function, which are the best way for i do this or a way alternative

23

Answer

Solution:

I think what you need are view partials. You can read on view partials in the ZF2 official documentation.

You have to create your partials and then you register them under yourtemplate_map inside theview_manager config.

'view_manager' => array(
    //...
    'template_map' => array(
        'my/form' => __DIR__ . '/../view/partials/form.phtml',
        'my/partial' => __DIR__ . '/../view/partials/partial.phtml',
    )
),

Then in every layout you can simply embed them like this:

echo $this->partial('my/form');
echo $this->partial('my/partial');

If you need to pass variables to your partials you can pass a second argument:

echo $this->partial('my/form', array('foo' => 'bar'));

People are also looking for solutions to the problem: image resizing - PHP: Out of memory as soon as upload_max_filesize is set

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.