[TYPO3-commerce] How-To: multiple images

Dmitry Pikhno dpi at goldenplanet.com
Tue Jul 31 09:42:38 CEST 2007


this example is using TYPO3 slimbox extension(lightbox) for image popup, 
so install it.


includeLibs.hackCommerce = fileadmin/scripts/user_commerce.inc

---------------------------
user_commerce.inc:
class user_commerce {
	var $cObj;
	
	function multipleImages($content, $conf)	{
		$images = explode(",", $content);
		if ($images){
			$i = 1;
			foreach($images as $image){
				$conf[$i.'.']['file'] = $conf['path'] . '/' . $image;
				$new .= $this->cObj->IMAGE($conf[$i.'.']);
				if ($conf['limit'] == $i) break;
				$i++;
			}
		}
		return $new;
	}
}
-------------------------


lib.tx_commerce.products.fields.images = STDWRAP
lib.tx_commerce.products.fields.images  {
	file.maxW = 80
	preUserFunc = user_commerce->multipleImages
	preUserFunc.path = uploads/tx_commerce
	preUserFunc{
		1{
			wrap=|
  			imageLinkWrap = 1
  			imageLinkWrap {
     				enable = 1
     				typolink {
parameter.cObject = IMG_RESOURCE
parameter.cObject.file.import.data = TSFE:lastImageInfo|origFile     	 
parameter.cObject.file.maxW = {$styles.content.imgtext.slimbox.maxW}
parameter.cObject.file.maxH = {$styles.content.imgtext.slimbox.maxH}
ATagParams = rel="lightbox"
ATagParams.override = rel="lightbox[sb{field:uid}]"
ATagParams.override.if.isTrue = {$plugin.tt_news.slimbox.navigable}
ATagParams.insertData = 1
				}
   			}
		}
		# my example is for <=6 images
		2 < .1	
		3 < .1
		4 < .1
		5 < .1
		6 < .1
	}
}



plugin.tx_commerce_pi1 {
	listView.products.fields.images {
		#in list view we need just one image without js popup.
		preUserFunc.1.imageLinkWrap >
		preUserFunc.limit = 1
		preUserFunc.1.file.maxW = 130
	}
	singleView.products.fields.images {
		#remove general link
		stdWrap.typolink.parameter = 0
	}
}




Will be glad to hear your comments how to improve or/and simplify this 
TS or other ways to display several images per product.
In general if someone has other tips and tricks for commerce please 
share you knowledge with community. Please add "How-To:" pattern in 
front of such message.



-- 
Dmitry Pikhno
Web-Developer
Golden Planet
mailto:dpi at goldenplanet.com


More information about the TYPO3-project-commerce mailing list