zend framework2 - ZF2 Nesting Views in View Helper -
I am trying to create a ZF2 view assistant who posts different blogs of the display formats. Post made of header, body and footer.
I have tried to create an assistant to see using the nesting example.
// Post Assistant
Public Function __Inoc (PostInterface $ post, $ is_single = true) {$ view_model = New ViewModel (); $ View_model- & gt; Setmetlet ('editorial / partial / complete'); $ View_model- & gt; Set variables ('object', $ post); $ View_model- & gt; Set Variable ('is_single' is $ is_single); $ Body_model = New ViewModel (); $ Body_model- & gt; Setmetlet ('editorial / partial / xx_display_format_partial_xx'); $ Body_model- & gt; Set variables ('object', $ post); $ View_model- & gt; Add Chald ($ body_model, 'body'); ... to repeat for header and footer $ the-> getView () - & gt; Render ($ view_model); }
// editorial / partial / complete.file
per $ echo-> header; Echo $ - THIS- & gt; the body; Echo $ the-> Foot Note;
I did not get any error while refusing the visual assistant. The problem is that there is no output either
am I trying to make even possible ? If so, what am I doing?
Try this solution
It says that the PF renderer actually The idea does not offer a tutorial that shows how it works from the point of view, and it works because in that situation the scene is provided by Zend \ View \ View :: Render ()
So, the solution to your problem is to present your nested ideas in the same way as Is light.
Upgrade
Or you can simplify it too. Simply submit your ideas separately and add each output to your main view as a variable. See an example:
$ view = new ViewModel (); $ Body = New ViewModel (); $ Header = new view modal (); $ Footnote = new view modell (); // ... some setup $ view- & gt; Set Variable ('body', $ this- & gt; getView () - & gt; render ($ body)); $ View- & gt; Set Variable ('header', $ this-> getView () - & gt; render ($ header)); $ View- & gt; Set Variable ('Footer', $ this- & gt; getView () - & gt; Render ($ footer)); Return $ $- & gt; GetView () - & gt; Render ($ view);
It should be more optimized according to your results the same results. Due to Zend \ View \ View \ Render (), the code is more complex because it oversees all possible cases, but you do not need to do this for your work.
Comments
Post a Comment