[TYPO3-ect] my first view on lib / div

Ernesto Baschny [cron IT] ernst at cron-it.de
Sat Sep 29 01:56:05 CEST 2007


Daniel Pötzinger wrote: on 28.09.2007 22:32:

>>> something like:
>>> function asImage($name,$configuration) {
>>>         $lConf=$this->configurator->get($configuration);
>>>         if (is_array($lConf)) {               $lConf['file'] .=
>>> $this->get('name');                   $cObject =
>>> $this->findCObject();                   return $cObject->IMAGE($lConf);
>>>         }
>>> }
>>
>> This is usually not very flexible (hardcoding the CType "IMAGE" in a
>> function). I would always suggest:
>>
>> Add the data you need for rendering the image (here the filename) to
>> $cObj->data and then just render a cObject using cObjGetSingle. Maybe
>> the data in your cObject already contains the image filename (and other
>> data relevant to the row you are rendering), then you don't need to do
>> anything in PHP.
>>
>> This way the admin is free to make it a GIFBUILDER, a TEXT (e.g. for
>> some plain-text version) or maybe even a COA with more stuff, etc.
>>
>> But think about it, I would then call that method:
>>
>>     renderContentObject($configurationKey)
>>
>> and you can then render any TypoScript cObject with the current model's
>> data using a specific configurationKey, which might of course be an
>> IMAGE.
>>
> Well thanks but if I want to output a certain field in my view this
> field has to be interpreted in a certain way. For text this is HTML and
> for an Image it is IMAGE.
> So I guess it fully fits into the concept of a view - and the name of
> the function is not asContentObject but it is asImage. And this is used
> in the template so if I dont want it as Image I put there asSomethingElse..

Well, that might be your concept, that an image has to be rendered as a
"<img>" tag, but others might have very different concepts on how to
render an image: in a div-block with a caption, maybe with a frame
around it, maybe with some masking over it or with a watermark
(GIFBUILDER). In your setup you can only generate a <img> tag with a
certain width / height. If this is enough for you, ok, but I wouldn't
like to loose the flexibility we have in TypoScript.

Cheers,
Ernesto


More information about the TYPO3-team-extension-coordination mailing list