Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony: difference between Action+partial and a Component

Tags:

symfony1

why should i use a component instead of an action that renders a partial?

If actions can render partials, when is better using components?

Give me light about it..

Javi

like image 603
ziiweb Avatar asked Apr 15 '10 13:04

ziiweb


1 Answers

components are used when you want to include some kind of block in different parts of the site (for example, a "Top 10 Sales" or something similar) - that requires some controller code to render. You include a component's output in another template of an action / partial / another component by using

include_component($module_name, $component_name, array('var1' => $var1));
an action is supposed to be called directly by the browser , so you can't include it's output in another template (without some kind of hack) Think of components as a reusable block of html that can get included anywhere, vs actions that are the whole page rendered and sent to the browser
like image 146
matei Avatar answered Oct 13 '22 21:10

matei