[TYPO3-ect] MVC and image rendering...
Steffen Kamper
steffen at dislabs.de
Sun Mar 4 09:42:36 CET 2007
"R. van Twisk" <typo3 at rvt.dds.nl> schrieb im Newsbeitrag
news:mailman.52516.1172971942.21067.typo3-team-extension-coordination at lists.netfielders.de...
> Elmar HInz wrote:
>> Am Sat, 03 Mar 2007 17:46:14 -0500 schrieb R. van Twisk:
>>
>>
>>> hey Guys,
>>>
>>>
>>> since I am not to the whole MVC thing I have a question.
>>>
>>> It's about image rendering... Now I could render the image in my model,
>>> where I go over my array anyways....
>>>
>>> But actually it should be done in my view, right?
>>>
>>> If so, does it mean I need to pick up teh array from
>>> my view again in some function and render images.
>>> Or is it fine if I render images in my model?
>>>
>>> I am trying to find a efficient solution.... On the other hand teh array
>>> is small
>>> and will stay below 18 images orso..
>>>
>>>
>>> Ries
>>>
>>
>> Hi Ries,
>>
>> there is never the one and only solution. For images one can discuss if
>> the rendering belongs into the model or the view. It also depends on what
>> you mean by "rendering".
>>
>> I assume the data about the image list results from a DB query. That
>> query
>> belongs into the model. I would load the resulting list of data into a
>> tx_lib_object as data transporter. In the view I would generate the
>> images
>> probably by using tx_lib_image (or an inherited class of it). Typically
>> you iterate over the transport container with a rewind-valid-next loop.
>>
>>
>> Regards
>>
>> Elmar
>>
>>
>>
>>
> Hey Elmar,
>
> what I currently do is assign the data to the view,
> and then call a function in the view to render the images.
>
> I strongly feel that rendering is up to the view, not to the model.
> The raw image comes from the model, and the view needs to generate
> it at appropriate size for viewing.
>
> I tried to follow eFAQ on how to assign data. But the problem is that
> rows are stored as a object, and even the array is stored as a object.
> That was something that smarty didn't like to much (and I didn't had
> time to figure out, since I think smarty can handle that well...)
>
> Currently tx_lib_image is of not much use since I really like to have
> image configuration in TS like this:
>
> image = IMAGE
> image.file.maxW = 120
> image.file.maxH = 120
> image.file.import.field = tmpfile
>
> By doing it that way image rendering get's extremely simple
> and I have full GIFBUILDER options available. Using tx_lib_image
> I have to copy values from TS config and call functions to tx_lib_image
> which will take up to much of my precious resources, and takes
> all my flexibility away.
>
> Currently it feels like that tx_lib_object and phpview are a married
> couple.
> and that tx_lib_object and smarty are like water and fire....
> May be it's the whole SPL thing I don't like, I am not sure yet but it
> looks
> like a wrapper around PHP's variables. Properly it's just me, but
> currently I
> see it as a resource hook...
>
>
> What I normally do is get a dataset from a DB and store it in a associate
> array.
> Then I pass that dataset directly to smarty (often as a reference) and I
> let
> smarty render the whole thing.
>
> When I need to do modifications on that array I would do it in the model,
> and then return the dataset. Buttom line is that when it comes out of my
> model.
> It's raw data, native variables and fast to render by smarty.
>
> Above is just what I currently experience, I might not have seen the light
> yet!!!
>
> All other parts I like a lot so far (the whole MVC thing) it's just data
> handling
> I don't like much yet.
>
>
> Ries
>
>
Yes, smarty is different to other views. Because smarty has an own
Datastorage it would be storing the same data twice.
More information about the TYPO3-team-extension-coordination
mailing list