Zum Inhalt springen

Fragen zu CD Collection aus Video Tutorial

Erstellt am 28. Februar 2006 · 1 Antwort · letzte Antwort am 1. März 2006

Tags: Frage

T0m ·

hallo

ich habe die Extension wie im Video gezeigt nachgebaut. Leider hat sich seitdem doch etwas getan und manche Dinge sind in der Version 3.8.1 bzw 4.0 beta 2 nicht mehr so wie damals.
Darauf sind auch schon ein paar Leute im Forum gestossen, wenn ich mir die Beitraege im Forum anseh die man zum Thema CD Collection bekommt.

Allerdings hab ich es noch nicht hinbekommen den Fehlenden Kategorie Teil zu implementieren.
Ich habe im Backend schon die Auswahlbox der Kategorie, aber komm einfach nicht drauf wo und wie ich in dem Code was einfueg, dass die Ausgabe auf die im BE gewaehlte Kategorie beschraenkt.

Wenn die Extension vollstaendig ist und funktioniert koennt man die auch mal ins Repository stellen, vielleicht erbarmt sich auch jemand ein neues Videotutorial zu machen ?! 🙂

Hier mal meine Codezeilen (class-file.php und ext_tables.php)

class File

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

class user_trcdcollection_pi1 extends tslib_pibase {
	var $prefixId = 'user_trcdcollection_pi1';		// Same as class name
	var $scriptRelPath = 'pi1/class.user_trcdcollection_pi1.php';	// Path to this script relative to the extension dir.
	var $extKey = 'user_trcdcollection';	// The extension key.
	var $pi_checkCHash = TRUE;
	var $categoryCache = array();
		

	/**
	 * Main Funktion - Unterscheidung singleView oder listView
	 */
	function main($content,$conf)	{
		switch((string)$conf['CMD'])	{
			case 'singleView':
				list($t) = explode(':',$this->cObj->currentRecord);
				$this->internal['currentTable']=$t;
				$this->internal['currentRow']=$this->cObj->data;
				return $this->pi_wrapInBaseClass($this->singleView($content,$conf));
			break;
			default:
				if (strstr($this->cObj->currentRecord,'tt_content'))	{
					$conf['pidList'] = $this->cObj->data['pages'];
					$conf['recursive'] = $this->cObj->data['recursive'];
				}
				return $this->pi_wrapInBaseClass($this->listView($content,$conf));
			break;
		}
	}
	
	/**
	 * listView: Zeigt Uebersichtsliste der Eintraege an
	 */
	function listView($content,$conf)	{
		$this->conf=$conf;		// Setting the TypoScript passed to this function in $this->conf
		$this->pi_setPiVarDefaults();
		$this->pi_loadLL();		// Loading the LOCAL_LANG values
		
		$lConf = $this->conf['listView.'];	// Local settings for the listView function

		$this->templateFileContent = $this->cObj->cObjGetSingle($lConf['altTemplateFile'],$lConf['altTemplateFile.']);
		#debug(array($this->templateFileContent));

		if ($this->piVars['showUid'])	{	// If a single element should be displayed:
			$this->internal['currentTable'] = 'user_trcdcollection_cds';
			$this->internal['currentRow'] = $this->pi_getRecord('user_trcdcollection_cds',$this->piVars['showUid']);
	
			$content = $this->singleView($content,$conf);
			return $content;
		} else {
			$items=array(
				'1'=> $this->pi_getLL('list_mode_1','Mode 1'),
				'2'=> $this->pi_getLL('list_mode_2','Mode 2'),
				'3'=> $this->pi_getLL('list_mode_3','Mode 3'),
			);
			if (!isset($this->piVars['pointer']))	$this->piVars['pointer']=0;
			if (!isset($this->piVars['mode']))	$this->piVars['mode']=1;
	
				// Initializing the query parameters:
			list($this->internal['orderBy'],$this->internal['descFlag']) = explode(':',$this->piVars['sort']);
			$this->internal['results_at_a_time']=t3lib_div::intInRange($lConf['results_at_a_time'],0,1000,4);		// Number of results to show in a listing.
			$this->internal['maxPages']=t3lib_div::intInRange($lConf['maxPages'],0,1000,2);;		// The maximum number of "pages" in the browse-box: "Page 1", "Page 2", etc.
			$this->internal['searchFieldList']='artist,album_title,desription,link_to_website';
			$this->internal['orderByList']='uid,artist,album_title';

$this->conf['category.']['field']
	
				// Get number of records:
			$res = $this->pi_exec_query('user_trcdcollection_cds',1);
			list($this->internal['res_count']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
	
				// Make listing query, pass query to SQL database:
			$res = $this->pi_exec_query('user_trcdcollection_cds');
			$this->internal['currentTable'] = 'user_trcdcollection_cds';
	
				// Put the whole list together:
			$fullTable='';	// Clear var;
		#	$fullTable.=t3lib_div::view_array($this->piVars);	// DEBUG: Output the content of $this->piVars for debug purposes. REMEMBER to comment out the IP-lock in the debug() function in t3lib/config_default.php if nothing happens when you un-comment this line!
	
				// Adds the mode selector.
		#	$fullTable.=$this->pi_list_modeSelector($items);
	
				// Adds the result browser:
			$fullTable.=$this->pi_list_browseresults();
							// Adds the whole list table
			$fullTable.=$this->pi_list_makelist($res);
	
				// Adds the search box:
			$fullTable.=$this->pi_list_searchBox();
	

	
				// Returns the content from the plugin.
			return $fullTable;
		}
	}
	/**
	 * [Put your description here]
	 */
	function singleView($content,$conf)	{
		$this->conf=$conf;
		$this->pi_setPiVarDefaults();
		$this->pi_loadLL();
		
	
			// This sets the title of the page for use in indexed search results:
		if ($this->internal['currentRow']['title'])	$GLOBALS['TSFE']->indexedDocTitle=$this->internal['currentRow']['title'];
	
		$content='<div'.$this->pi_classParam('singleView').'>
			<h2>Record "'.$this->internal['currentRow']['uid'].'" from table "'.$this->internal['currentTable'].'":</h2>
	<table>
			/* REMOVED TABLE FOR NON TEMPLATE USAGE */
	</table>	<p>'.$this->pi_list_linkSingle($this->pi_getLL('back','Back'),0).'</p></div>'.
		$this->pi_getEditPanel();
	
		return $content;
	}
	/**
	 * [Put your description here]
	 */
	function pi_list_row($c)	{
		$editPanel = $this->pi_getEditPanel();
		if ($editPanel)	$editPanel='<td>'.$editPanel.'</td>';
	
		if($this->templateFileContent) {
			$dataRowContent = $this->cObj->getSubpart($this->templateFileContent,'###DATA_ROW'.($c%2 ? '1' : '2').'###');
			
			$substArray=array();
			$substArray['###ARTIST###'] = $this->getFieldContent("artist");
			$substArray['###ALBUM_TITLE###'] = $this->getFieldContent("album_title");
			$substArray['###COVERIMAGE###'] = $this->getFieldContent("coverimage");
			$substArray['###CATEGORY###'] = $this->getFieldContent("category");
			$substArray['###EDITPANEL###'] = $editpanel;
			
			return $this->cObj->substituteMarkerArrayCached($dataRowContent,$substArray);
			
		} else {
			
			return '<tr'.($c%2 this-="">pi_classParam('listrow-odd') : '').'>
				<td valign="top"><p>'.$this->getFieldContent('artist').'</p></td>
				<td valign="top"><p>'.$this->getFieldContent('album_title').'</p></td>
				<td valign="top"><p>'.$this->getFieldContent('coverimage').'</p></td>
				<td valign="top"><p>'.$this->getFieldContent('category').'</p></td>
			</tr>';
		}
	}
	/**
	 * [Put your description here]
	 */
	function pi_list_header()	{
		if($this->templateFileContent) {
			$dataRowContent = $this->cObj->getSubpart($this->templateFileContent,'###HEADER_ROW###');
			
			$substArray=array();
			$substArray['###ARTIST###'] = $this->getFieldHeader_sortLink("artist");
			$substArray['###ALBUM_TITLE###'] = $this->getFieldHeader_sortLink("album_titlet");
			$substArray['###COVERIMAGE###'] = $this->getFieldHeader("coverimage");
			$substArray['###CATEGORY###'] = $this->getFieldHeader("category");
			
			return $this->cObj->substituteMarkerArrayCached($dataRowContent,$substArray);
		
		} else {
			
			return '<tr'.$this->pi_classParam('listrow-header').'>
				<td><p>'.$this->getFieldHeader_sortLink('artist').'</p></td>
				<td><p>'.$this->getFieldHeader_sortLink('album_title').'</p></td>
				<td nowrap=""><p>'.$this->getFieldHeader('coverimage').'</p></td>
				<td nowrap=""><p>'.$this->getFieldHeader('category').'</p></td>
			</tr>';
		}
	}
	/**
	 * [Put your description here]
	 */
	function getFieldContent($fN)	{
		switch($fN) {
			case 'uid':
				return $this->pi_list_linkSingle($this->internal['currentRow'][$fN],$this->internal['currentRow']['uid'],1);	// The "1" means that the display of single items is CACHED! Set to zero to disable caching.
			break;
			case "date_of_purchase":
					// For a numbers-only date, use something like: %d-%m-%y
				return strftime('%A %e. %B %Y',$this->internal['currentRow']['date_of_purchase']);
			break;
			case 'album_title':
			case 'artist':
				return $this->pi_list_linkSingle($this->internal['currentRow'][$fN],$this->internal['currentRow']['uid'],1);	// The "1" means that the display of single items is CACHED! Set to zero to disable caching.
			break;
			case "desription":
				return $this->pi_RTEcssText($this->internal['currentRow']['desription']);
			break;
			case "coverimage-old":
				$imgTSConfig = $this->conf['coverImageCObject.'];
				$imgTSConfig['file'] = 'uploads/tx_usertrcdcollection/'.$this->internal['currentRow'][$fN];
				return $this->cObj->IMAGE($imgTSConfig);
			break;
			case "coverimage":
				$imgTSConfig=$this->conf['coverImageCObject.'];
				$bilder=t3lib_div::trimExplode(",",$this->internal['currentRow']["$fN"]);
				$i=0;
				$spalten=3;
				foreach($bilder as $bild)
				{
					if(($i%$spalten) == 0)
						{
							$content.='<br /><br />';
						}
					$imgTSConfig['file']='uploads/tx_usertrcdcollection/'.$bild;
					$content.=$this->cObj->IMAGE($imgTSConfig);
					$content.= ' ';
					$i++;
				}
				return $content;
			break;
			case "category":
				if (!count($this->categoryCache)) {
					$query = 'SELECT * FROM user_trcdcollection_category WHERE pid='.intval($GLOBALS["TSFE"]->id).
					$this->cObj->enableFields('user_trcdcollection_category'); // looks up fields
					$res = mysql(TYPO3_db, $query);
					while($row=mysql_fetch_assoc($res)) {
						$this->categoryCache[$row['uid']] = $row;
					}
				}
				return htmlspecialchars($this->categoryCache[$this->internal["currentRow"]['category']]['title']);
			default:
				return $this->internal['currentRow'][$fN];
			break;
		}
	}
	/**
	 * [Put your description here]
	 */
	function getFieldHeader($fN)	{
		switch($fN) {
			
			default:
				return $this->pi_getLL('listFieldHeader_'.$fN,'['.$fN.']');
			break;
		}
	}
	
	/**
	 * [Put your description here]
	 */
	function getFieldHeader_sortLink($fN)	{
		return $this->pi_linkTP_keepPIvars($this->getFieldHeader($fN),array('sort'=>$fN.':'.($this->internal['descFlag']?0:1)));
	}
}



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

ext_tables.php

<?php
if (!defined ('TYPO3_MODE')) 	die ('Access denied.');

t3lib_extMgm::allowTableOnStandardPages("user_trcdcollection_cds");

$TCA["user_trcdcollection_cds"] = Array (
	"ctrl" => Array (
		"title" => "LLL:EXT:user_trcdcollection/locallang_db.php:user_trcdcollection_cds",		
		"label" => "album_title",	
		"tstamp" => "tstamp",
		"crdate" => "crdate",
		"cruser_id" => "cruser_id",
		"default_sortby" => "ORDER BY album_title",	
		"delete" => "deleted",	
		"enablecolumns" => Array (		
			"disabled" => "hidden",
		),
		"dynamicConfigFile" => t3lib_extMgm::extPath($_EXTKEY)."tca.php",
		"iconfile" => t3lib_extMgm::extRelPath($_EXTKEY)."icon_user_trcdcollection_cds.gif",
	),
	"feInterface" => Array (
		"fe_admin_fieldList" => "hidden, artist, album_title, date_of_purchase, link_to_website, coverimage, category, desription",
	)
);


t3lib_extMgm::allowTableOnStandardPages("user_trcdcollection_category");

$TCA["user_trcdcollection_category"] = Array (
	"ctrl" => Array (
		"title" => "LLL:EXT:user_trcdcollection/locallang_db.php:user_trcdcollection_category",		
		"label" => "title",	
		"tstamp" => "tstamp",
		"crdate" => "crdate",
		"cruser_id" => "cruser_id",
		"default_sortby" => "ORDER BY title",	
		"delete" => "deleted",	
		"enablecolumns" => Array (		
			"disabled" => "hidden",
		),
		"dynamicConfigFile" => t3lib_extMgm::extPath($_EXTKEY)."tca.php",
		"iconfile" => t3lib_extMgm::extRelPath($_EXTKEY)."icon_user_trcdcollection_category.gif",
	),
	"feInterface" => Array (
		"fe_admin_fieldList" => "hidden, title",
	)
); 
/* Fuegt die Auswahl der Kategorie zu Content Element Seite hinzu */
$tempColumns = Array (
	"user_trcdcollection_cdcategory" => Array (		
		"exclude" => 1,		
		"label" => "LLL:EXT:user_trcdcollection/locallang_db.php:tt_content.user_trcdcollection_cdcategory",		
		"config" => Array (
			"type" => "select",	
			"foreign_table" => "user_trcdcollection_category",	
			"foreign_table_where" => "ORDER BY user_trcdcollection_category.uid",	
			"size" => 1,	
			"minitems" => 0,
			"maxitems" => 1,
		)
	),
);

t3lib_div::loadTCA('tt_content');

t3lib_extMgm::addTCAcolumns("tt_content",$tempColumns,1); /* Fuegt die Auswahl der Kategorie zu Content Element Seite hinzu */ 
$TCA["tt_content"]["types"]["list"]["subtypes_addlist"][$_EXTKEY."_pi1"]="user_trcdcollection_cdcategory;;;;1-1-1"; 
/* Fuegt die Auswahl der Kategorie zu Content Element Seite hinzu: tt_content . "extended field list name;;;;db relation"  */



$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_pi1']='layout,select_key';


t3lib_extMgm::addPlugin(Array('LLL:EXT:user_trcdcollection/locallang_db.php:tt_content.list_type_pi1', $_EXTKEY.'_pi1'),'list_type');


t3lib_extMgm::addStaticFile($_EXTKEY,'pi1/static/','CD Collection');



?>
T0m ·

ok Antwort auf die Frage Beschraenkung der Category kann ich selbst geben

dazu Zeile 70 aus der class Datei aendern in :

$res = $this->pi_exec_query('user_trcdcollection_cds',1,'AND category='.$this->cObj->data['user_trcdcollection_cdcategory'].'');

und Zeile 74 aendern in:

$res = $this->pi_exec_query('user_trcdcollection_cds',0,'AND category='.$this->cObj->data['user_trcdcollection_cdcategory'].'');

Vielleicht hilft das manchen, die so wie ich auch erstmal an der oder sogar an vorheriger Stelle haengen geblieben sind.