Help with Zend View

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with Zend View

Александр Шелковский
Hello.

Could someone explain me few moments with View.

1) Why this code in PhpRendererStrategy needed? What it do?
        if (empty($result)) {
            $placeholders = $renderer->plugin('placeholder');
            $registry     = $placeholders->getRegistry();
            foreach ($this->contentPlaceholders as $placeholder) {
                if ($registry->containerExists($placeholder)) {
                    $result = (string) $registry->getContainer($placeholder);
                    break;
                }
            }
        }

2) What view_model plugin do? Why this code PhpRendere needed?
$helper = $this->plugin('view_model');
$helper->setCurrent($model);

Regards,
Alex.
Reply | Threaded
Open this post in threaded view
|

Re: Help with Zend View

developer10
This post has NOT been accepted by the mailing list yet.
Sorry for not giving a constructive and issue-related advice but here it is: Move to ZF2! View layer is really simplified!
Reply | Threaded
Open this post in threaded view
|

Re: Help with Zend View

weierophinney
Administrator
In reply to this post by Александр Шелковский
-- Александр Шелковский <[hidden email]> wrote
(on Saturday, 22 September 2012, 04:13 AM +0700):

> Hello.
>
> Could someone explain me few moments with View.
>
> 1) Why this code in PhpRendererStrategy needed? What it do?
>         if (empty($result)) {
>             $placeholders = $renderer->plugin('placeholder');
>             $registry     = $placeholders->getRegistry();
>             foreach ($this->contentPlaceholders as $placeholder) {
>                 if ($registry->containerExists($placeholder)) {
>                     $result = (string) $registry->getContainer($placeholder);
>                     break;
>                 }
>             }
>         }

This code grabs the two most common variables for content, "article"
and "content", and checks to see if there is a placeholder container for
them. If so, it pulls that value and uses it as the result. The
view layer uses placeholders to temporarily store content rendered from
child view models so that it can then later inject the layout.

> 2) What view_model plugin do? Why this code PhpRendere needed?
> $helper = $this->plugin('view_model');
> $helper->setCurrent($model);

The ViewModel plugin allows you direct access to the current ViewModel
object, if one was used in the current call to render() -- which allows
you to manipulate it. This can be useful for discovering the template
name you were invoked under, or getting access to the parent view model
(typically the layout view model, but not always) or child view models.

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
Reply | Threaded
Open this post in threaded view
|

Re: Help with Zend View

Александр Шелковский
Hello.

Thx for the anser Matthew. But I still have few questions left.

1) I understand what is used for placeholders. But I can't understand how it may used. Currently (I mean in MVC ussage) ZendView always get content from result. Could you give an example of how this featur may be used?

Regards,
Alex.