Zum Inhalt springen

html-template - subpart - typoscript problem mit Bild

Erstellt am 23. November 2008 · 4 Antworten · letzte Antwort am 29. November 2008

Tags: Frage

sefer ·

Hi,
ich mache gerade meine ersten gehversuche mit der Erstellung von Html-Templates. ich habe verschieden Vorlagen und damit baue ich mir gearade das benötigte zusammen.
Vorlagen:
http://wiki.typo3.org/index.php/Extension_Development,_using_HTML-Templates
http://www.traum-projekt.com/forum/73-workshops-und-tutorials/101411-workshop-typo3-extension-programmierung-7.html

Mein Problem:
Ich möchte eigentlich nur das die Bilder in meiner Listenansicht mit einer Maximalbreite von 40px angezeigt werden sollen!

<?php
	//configure image
	$config = array();
	$config['file'] = $this->conf['folder.'][path_uploads].$row['picture'];
	$config['file.'][maxW] ='40';
	$config['file.']['title'] ='TEST';
	$image = $this->cObj->IMAGE($config);

$markerArray['###'.strtoupper($marker).'###'] = $image;
	t3lib_div::debug($image, 'image');
?>

Ausgabe:
<img src="uploads/tx_sdcars2/7-Car.jpg" width="1200" height="450" border="0" alt="" title="" />

Also das Bild wird ausgegeben, aber nicht in der gewünschten Größe.

Woran kann es liegen?

Danke!
Hier des gesamte Code:

<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2008 Sefer
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

require_once(PATH_tslib.'class.tslib_pibase.php');


/**
 * Plugin 'SD CARS' for the 'sd_cars_2' extension.
 *
 * @author	Sefer 
 * @package	TYPO3
 * @subpackage	tx_sdcars2
 */
class tx_sdcars2_pi1 extends tslib_pibase {
	var $prefixId      = 'tx_sdcars2_pi1';		// Same as class name
	var $scriptRelPath = 'pi1/class.tx_sdcars2_pi1.php';	// Path to this script relative to the extension dir.
	var $extKey        = 'sd_cars_2';	// The extension key.
	var $pi_checkCHash = true;
	
	/**
	 * Main method of your PlugIn
	 *
	 * @param	string		$content: The content of the PlugIn
	 * @param	array		$conf: The PlugIn Configuration
	 * @return	The content that should be displayed on the website
	 */
	function main($content,$conf)	{
		$this->conf=$conf; //muss eigentlich nicht noch var $conf oben in der Klasse definiert werden?


		//$content="TEST2<br />";
		
		switch ($this->piVars['action']){

					case "view_list":
						$content.= $this->view_list();
					break;
					
					case "view_detail":
						$content.= $this->zurueck("zurück");
						$content.= $this->view_detail();
						$content.= $this->zurueck("zurück");
					break;
								
					default:
						$content.= $this->view_list();
					break;
				}

		return $this->pi_wrapInBaseClass($content);
	}
	
	function view_detail(){	
		//t3lib_div::debug($this->conf, 'conf');

		 // Get the template
		 $this->templateCode = $this->cObj->fileResource($this->conf['templateFileDetail']);

    	 //Überprüfe ob Template vorhanden?
		if ($this->templateCode==""){
			$content= "<h3> KEIN HTML TEMPLATE GEFUNDEN IN:</h3>".$this->conf['templateFileDetail'];
		}		 
		 
		 // Get the parts out of the template
		 $template['total'] = $this->cObj->getSubpart($this->templateCode,'###TEMPLATE###');
		 
		 // Fill marker
		 $markerArray['###MARKER1###'] = 'content for marker 1';
		 $markerArray['###MARKER2###'] = 'content for marker 2';
		 
		 // Finalize and create the content by replacing the "content" marker in the template
		 $content.= $this->cObj->substituteMarkerArrayCached($template['total'],$markerArray);
		 return $content;
}
	
	/**
	 * Shows a list of database entries
	 *
	 * @param	string		$content: content of the PlugIn
	 * @param	array		$conf: PlugIn Configuration
	 * @return	HTML list of table entries
	 */
function view_list()	{
		//t3lib_div::debug($this->conf, 'conf');
   
   // configure the typolink
 $this->local_cObj = t3lib_div::makeInstance('tslib_cObj');
 $this->local_cObj->setCurrentVal($GLOBALS['TSFE']->id);
 $this->typolink_conf = $this->conf['typolink.'];
 $this->typolink_conf['parameter.']['current'] = 1;

		 // Get the template
		 $this->templateCode = $this->cObj->fileResource($this->conf['templateFileList']);

    	 //Überprüfe ob Template vorhanden?
		if ($this->templateCode==""){
			$content= "<h3> KEIN HTML TEMPLATE GEFUNDEN IN:</h3>".$this->conf['templateFileList'];
		}		 
		 
		  // Get the parts out of the template
 $template['total'] = $this->cObj->getSubpart($this->templateCode,'###TEMPLATE###');
 $template['item'] = $this->cObj->getSubpart($template['total'],'###ITEM###');
 
 
 
   // Your SQL query comes here:
   $from="*";
   $from_table="tx_sdcars2_vehicles";
   $where="deleted=0 AND hidden=0";
   $orderBy="";
 	$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($from,$from_table,$where,$orderBy);
 
 	 // configure typolink
		 $temp_conf = $this->typolink_conf;
		 $temp_conf['useCacheHash']=$this->allowCaching;                            
		 $temp_conf['no_cache']=!$this->allowCaching;
		 $temp_conf['parameter.']['wrap'] = "|,".$GLOBALS['TSFE']->type;


   // Loop through query result
 	while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {	 	
		  // Fill marker AS ARRAY
		 $arrayAll = array('uid', 'name','vehicle_type',
							'producer','model','year_of_construstion',
							'price','vat','description','sold','in_showroom',
							'picture','sales_price','purchase_price',
							'cost_transport','cost_other','cost_description');
			 foreach ($arrayAll as $marker) {			 			  
		   		if ($marker=="uid"){
		   			// Fill wrapped subpart marker
		   			$temp_conf['additionalParams'].= '&'.$this->prefixId.'[action]=view_detail&'.$this->prefixId.'[uid]='.$row['uid'];
					$wrappedSubpartContentArray['###LINK_UID###'] = $this->local_cObj->typolinkWrap($temp_conf);
											 
		   		}elseif($marker=="picture"){
		   			//configure image
					$config = array();
					$config['file'] = $this->conf['folder.'][path_uploads].$row['picture'];
					$config['file.'][maxW] ='40';
					$config['file.']['title'] ='TEEE';
					$image = $this->cObj->IMAGE($config);
		   			$markerArray['###'.strtoupper($marker).'###'] = $image;
		   			t3lib_div::debug($image, 'image');
		   		}else{
		   			$markerArray['###'.strtoupper($marker).'###'] = $row[$marker];
		   				
		   		}
			 }
			 
	    // add subpart into a string
	 	 $content_item .= $this->cObj->substituteMarkerArrayCached($template["item"], $markerArray,'', $wrappedSubpartContentArray);				
	 }//WHILE END
	 
	    
	 // Fill subpart marker
	 	$subpartArray['###CONTENT###'] = $content_item; 
 
  	// Finalize and create the content by replacing the marker in the template
 		$content = $this->cObj->substituteMarkerArrayCached($template['total'], $markerArray, $subpartArray,  $wrappedSubpartContentArray);
 
 
 return $content;	
}
			/************************************
		 * Die Funktion  zurueck
		 * @param string $zurueckText
		 * @return $content="back-link"
		 */

	 function zurueck($zurueckText){
	 	//So erzeugt man automatisch einen Link auf die Seite aktuelle Seite
	 	//Würde man einfach die Seite Aktualisieren, dann wird die postVariable erneut gesendet
	 	//$content.= '<br /><br />'.$this->pi_linkToPage('<< zurück!',$GLOBALS['TSFE']->id).'';
	 	$content.='<br /><br />   ';
	 	$content.='<a href="javascript:history.back()">>>'.$zurueckText.'<<</a>';
	 	
	 	return $content;
	 }
	 
	
}



if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/sd_cars_2/pi1/class.tx_sdcars2_pi1.php'])	{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/sd_cars_2/pi1/class.tx_sdcars2_pi1.php']);
}

?>
its7 ·

Hallo ,

ich benutze folgende Function.
Es funktioniert. Ich höffe dieser kleine Kode hilft dir.

function createimage($imgsrc) {
		$content = '';
		$img = array ();
		$img['file'] = $imgsrc;
	
		$img['file.']['maxW'] = '100px';
		$img['file.']['maxH'] = '100px';
		$img['params'] = 'class="mypic"';				
		
		$content = $this->cObj->IMAGE($img);	
		return $content;
		
}

its7

sefer ·
its7 schrieb

ich benutze folgende Function.
Es funktioniert. Ich höffe dieser kleine Kode hilft dir.

its7

Hi und Danke its7,

es ist ja derselbe Code. Ich habe es aber trotzdem versucht, es hat aber nichts gebracht!

Da muss irgendetwas grundsätzliches falsch laufen ,aber wiso nimmt er dann den richtigen Pfad?
komisch komisch komisch... #angry#

Bin mit meiner kleinen Extension fast fertig, es fehlt eigentlich nur noch dises Problemlösung mit dem bild.

Hat noch jemand ne idee?
Danke,Sefer!

sefer ·

Endlich!!!

Ich hatte, weshalb auch immer, ImageMagick deaktiviert.

Eine kleine eins in localconf.php und das wars:

$TYPO3_CONF_VARS['GFX']['im'] = '1'; // Modified or inserted by TYPO3 Install Tool.

Ciao'
Sefer