[TYPO3-ect] my first view on lib / div
Ernesto Baschny [cron IT]
ernst at cron-it.de
Fri Sep 28 11:59:53 CEST 2007
Daniel Pötzinger wrote: on 28.09.2007 01:50:
> BTW
>
> Where can I suggest functions for lib?
>
> e.g. a function like asImage() and printAsImage() would be nice in the
> view classes.
>
> 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.
Cheers,
Ernesto
More information about the TYPO3-team-extension-coordination
mailing list