[TYPO3-dev] Use header image uploaded by user in extension

Franz Koch typo.removeformessage at fx-graefix.de
Tue Aug 21 13:35:41 CEST 2007


Hi guys,

>> Look at http://pi-phi.de/t3v4/rendering.html (GERMAN!) last two 
>> code-blocks.
>>
>> Bernd
> 
> Hi Bernd
> Thank you, I knew it was something like that.

well - the shown solution is not the best, as too many things are 
hardcoded. I'd suggest something like that, so that you can do whatever 
you want with your images (f.e. transform them with gifbuilder):

--- TS --------------------------------
plugin.tx_yourplugin_pi1 {
	logo = IMAGE
	logo {
		file {
			import = uploads/your_upload_path/
			import.current = 1
			width = 200m
			# ... further settings
		}
		altText.field = yourAltTextField
		titleText.field = yourTitleTextField
		# ... further settings
	}
	# ... some other configuration of your plugin
}
----------------------------------------

--- PHP --------------------------------

class.tx_yourplugin_pi1 extends tslib_pibase {

   function main($content,$conf) {
     # in your constructor, create a local_cObject
     $this->local_cObject = t3lib_div::makeInstance('tslib_cObj');
     $this->conf = $conf;
     # ... further stuff
   }

   function whatever() {
     # wherever you now need an image or any other flexible TS object
     # simply do this, supposing that you have a array called "$row"
     # containing the full result row of your current db record and
     # and array "$this->conf" containing your plugins TS configuration

     $this->local_cObject->data = $row;
     $this->local_cObject->setCurrentVal($row['yourImageField']);
     $image = 
$this->local_cObj->cObjGetSingle($this->conf['logo'],$this->conf['logo.']);

   }
}
----------------------------------------

This is a far more better solution as it gives you all the power of TS.

--
Kind regards,
Franz Koch




More information about the TYPO3-dev mailing list