Symfony: difference between Action + partial and component

Why should I use a component instead of an action that makes it partial?

If actions can display partial, when is it better to use components?

Tell me about this.

Xavi

+5
source share
2 answers
Components

used when you want to include a block in different parts of the site (for example, "Top 10 sales" or something like that) - this requires some controller code. You include component output in another action template / partial / other component with

include_component ($ module_name, $ component_name, array ('var1' => $ var1));
the action should be called directly by the browser, so you cannot include its output in another template (without any hacking) Think of the components as a reusable html block that can be included anywhere, as well as the actions that appear on the page in general and sent to the browser.
+7
source

partial is a "template" that can be reused on any viewing page. its simple and quick. all $ data should be passed as a partial parameter. imo should be preferred if possible.

Component

" ", . , . , , - (.. /)

http://www.symfony-project.org/book/1_0/07-Inside-the-View-Layer#chapter_07_code_fragments

+5

All Articles