[Solar-talk] Partials/Tiles/Elements/Components/Something

Andreas Ravnestad andreas.ravnestad at gmail.com
Sun Nov 5 07:58:04 PST 2006


Travis Swicegood wrote:
> Andreas Ravnestad wrote:
>   
>> On 11/5/06, *Travis Swicegood* <development at domain51.com 
>> <mailto:development at domain51.com>> wrote:
>>
>>     Look through some of the existing app's templates for calls to
>>     $this->_partial() - I think that does exactly what you want.
>>
>>
>> That looks great, and in many cases it is exactly what I want :) 
>> However, I also want some more logic to go with it. I browsed the RoR 
>> documentation today and found [1] which is exactly what I want. Is 
>> this doable in Solar?
>>
>> [1] http://wiki.rubyonrails.com/rails/pages/UnderstandingComponents
>>     
>
> Ahh - I see what you're wanting now.  That is not directly available in 
> the view, however you could achieve the same result doing:
>
> $front = Solar::factory('Solar_Front_Controller');
> $component = $front->display('/controller/action');
>
> I would recommend handling these in the controller - see 
> Solar_Controller_Page::_preRender() for a place you could assign the 
> results of that in to the view.
>
> -T
>   

Excellent, this is pretty much exactly what I want :) What I did further 
was to add your hack to the class Solar_View:

    public function component($action)
    {
        $front = Solar::factory('Solar_Controller_Front');
        return $front->fetch($action);
    }

So now from any given template, I can do (for example):
    <?=$this->component('/forum/latest/5')?>

Pretty and perfect! Any chance something like this could officially be 
added to Solar?

-Andreas


More information about the solar-talk mailing list