[TYPO3-english] Render textpic in extension
Tomas Havner
tomas.havner at kansli.lth.se
Tue Aug 16 14:06:57 CEST 2011
Jigal van Hemert skrev 2011-08-16 10:53:
> Hi,
>
> On 16-8-2011 9:55, Tomas Havner wrote:
>> I'm trying to render a textpic-element in my extension. What I got so
>> far is:
>>
>> $TS['conf'] = 'IMGTEXT';
>> $TS['conf.']['text.']['10'] = 'TEXT';
>> $TS['conf.']['text.']['10.']['value'] = $bodytext;
>> $TS['conf.']['textPos'] = 17;
>> $TS['conf.']['imgList'] = $imgList;
>
> You can actually call IMGTEXT directly from your extension. I'd use:
>
> $imageTextConfiguration = array();
> $imageTextConfiguration['text.']['10'] = 'TEXT';
> $imageTextConfiguration['text.']['10.']['value'] = $bodytext;
> $imageTextConfiguration['textPos'] = 17;
> $imageTextConfiguration['imgList'] = $imgList;
>
>> $myCObj = new tslib_cObj();
>
> Use t3lib_div::makeInstance() to create new objects and not the
> new-operator.
> Besides, if you are making a pi_base extension (i.e. not using
> Extbase) then there is already an instance available:
>
> $this->cObj
>
>> $content = $myCObj->cObjGetSingle($TS['conf'],$TS['conf.']);
>
> As said earlier, you can directly call IMGTEXT:
>
> $content = $this->cObj->IMGTEXT($imageTextConfiguration);
>
> Note: is your configuration really complete? See example in [1]. Test
> it first in Typoscript (with a list of images from a directory) and
> use the working configuration in your extension...
>
> [1] http://goo.gl/ODsMV (TSref documentation)
>
Thank you!
When I added $imageTextConfiguration['imgPath'] = 'uploads/pics/'; the
images showed. But wrapped in tables :( It seems as IMGTEXT is not what
I was looking for. Found:
$TS['conf'] = ' < tt_content.textpic.20';
$TS['conf.']['text.']['20'] = 'TEXT ';
$TS['conf.']['text.']['20.']['value'] = $row['bodytext'];
$TS['conf.']['imgList'] = $imgList;
$TS['conf.']['imgList.'] = ' >';
$TS['conf.']['layout.']['key'] = 17;
$TS['conf.']['layout.']['key.'] = ' >';
in an old post, but it didn't work. Any thoughts?
Tomas
More information about the TYPO3-english
mailing list