ZF-2819: Allow ViewScript decorator to have access to content and to replace it


Several people have requested the ability to have access to decorator content within the view script rendered by the ViewScript decorator, as well as the ability to replace the content provided to it. This can be accomplished by doing the following:

  • add an additional variable to the view, 'content';
  • add the decorator itself as the 'decorator' view variable;
  • and allow a null value for the 'placement' option, which would allow you to replace the content instead of appending or prepending it.

You would then be able to either:

  • pass a null 'placement' option to the decorator at initialization
  • in your view script, call $this->decorator->setPlacement(null)

in order to make the content of the view script replace it.


Works as per the bullet points in the posted issue, with the exception that the value 'false' should be passed as the 'placement' decorator option when desiring to replace content.

Applied to trunk and 1.5 release branch.