开发者

SLOTS in Actions?

I'm just learning Symfony - with bought paper-book, electronic pdfs accessible for free on the net and the internet itself. I must admit I never saw so poorly written guides about certain topic (including all of the mentioned above). The开发者_如何学Cy often lack in basic details.

I don't know if it's just me missing some information, but I haven't seen clear indication on where SLOTS can be used in Symfony. I took by default that I can use them anywhere. So after quick check in VIEW (and saw that they were working), I got down to the work and used them in ACTION method ( executeIndex() ).

And then my many-hours-wasted run began. After tones of pages viewed on the net, trying different things (like enforcing Symfony to autoload classes, which should be autoloaded) and checking even unprobable ways to find any solution to make slots work, I eventually came to realisation that SLOTS can be used only in VIEWS in Symfony.

Is this correct, or still am I missing something?


You can use slots also in your actions:

$this->getResponse()->setSlot('mySlot', $myValue);

or

$this->getResponse()->setSlot('myPartialSlot', $this->getPartial('myPartial'));

This is explained in the chapter Slots (http://www.symfony-project.org/book/1_2/07-Inside-the-View-Layer)


Yes, you are correct. Slots are part of the view. They're just templates that can use variables that were defined in the action.

This should be a helpful page if you haven't found it already: http://www.symfony-project.org/book/1_2/07-Inside-the-View-Layer

The Symfony documentation is relatively good. You should check out some of the Zend Framework docs for a real treat :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜