ich beiße mir gerade an dieser Extension die Zähne aus - es ist nebenbei mein erster Kontakt mit php und mit Programmieren überhaupt. Also:
Ich möchte gern Sortier-Links auf der Seite einbinden, die die Ergebnisse z.B. nach price oder dimension auf- und absteigend sortieren. Fürs TS ist vom Autor vorgesehen:
plugin.tx_estateagent_pi1.listView.orderBy = name ASC
Das klappt auch, wenn man das Sortierkriterium im TS direkt ändert. Nur ist das halt sehr statisch (eine Sortiermöglichkeit pro PlugIn/Seite) und ich möchte Links anbieten, die die aktuelle Kategorie dynamisch sortieren.
Da habe ich eine Funktion gefunden in der Extension (class tx_estateagent_pi1), die wohl dafür gedacht ist, das zu machen:
function getFieldHeader_sortLink($fN) {
return $this->pi_linkTP_keepPIvars($this->getFieldHeader($fN),array('sort'=>$fN.':'.($this->internal['descFlag']?0:1)));
}
Leider macht sie das nicht, der erzeugte Link sieht so aus:
index.php?id=26&no_cache=1&L=0&tx_estateagent_pi1[extensionName]=Estate Agent&tx_estateagent_pi1[pointer]=0&tx_estateagent_pi1[sort]=price%3A1
//bzw. price:1 hinten
Die ListView ist einfach leer.
Die Funktion zum Rendering der ListView sieht komplett so aus, interessant wirds wohl ab
// New in Version 1.1.2
$orderBy = @$this->conf['listView.']['orderBy'];
if ($orderBy == "") $orderBy = 'date DESC';:
etwas weiter unten:
/**
* 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 listView($content,$conf) {
$this->viewMode = "listView";
$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->lConf = $lConf;
// Getting the template file
$this->templateFileContent = $this->cObj->cObjGetSingle($lConf['altTemplateFile'], $lConf['altTemplateFile.']);
if ($this->piVars['showUid']) { // If a single element should be displayed:
$this->internal['currentTable'] = 'tx_estateagent_estate';
$this->internal['currentRow'] = $this->pi_getRecord('tx_estateagent_estate',$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;
// 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,30); // geaendert auf 30 *** Number of results to show in a listing.
$this->internal['maxPages']=t3lib_div::intInRange($lConf['maxPages'],0,1000,1);; // The maximum number of "pages" in the browse-box: "Page 1", "Page 2", etc.
$this->internal['searchFieldList']='name,dimension,price,shortdescription,description';
$this->internal['orderByList']='uid,name,dimension,price'; // no Influence ?
// Getting the categories to show
$showCats = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'field_categorySelect', sDEF);
$this->showCats = explode(',', $showCats);
// If no category is selected: return error
if ($showCats == "") return $this->error("No categories selected for the FE Plugin.");
// Get number of records:
$countCats = count($this->showCats);
$query = "";
$i=1;
// pidList for the selected pages
$pidList = $this->pi_getPidList($this->conf['pidList'],$this->conf['recursive']);
foreach ($this->showCats AS $catNum)
{
if ($i == 1) {
// search only in the pidList and only the non-hidden etc. objects
$query .= 'FROM tx_estateagent_estate WHERE (pid IN ('.$pidList.')'.chr(10).$this->cObj->enableFields('tx_estateagent_estate').chr(10).")";
//first Category
$query .= " AND (find_in_set(".$catNum.",category)>0 ";
}
else {
// multiple Categories
$query .= "OR find_in_set(".$catNum.",category)>0 ";
}
$i++;
}
// New in Version 1.1.2
$orderBy = @$this->conf['listView.']['orderBy'];
if ($orderBy == "") $orderBy = 'date DESC';
$query .= ") ORDER BY $orderBy";
$res = $this->pi_exec_query('tx_estateagent_estate',0,'','','','',$query);
$resCount = $this->pi_exec_query('tx_estateagent_estate',1,'','','','',$query);
list($this->internal['res_count']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($resCount);
$this->internal['currentTable'] = 'tx_estateagent_estate';
// Put the whole list together:
$fullTable=''; // Clear var;
// Adds the whole list table
if($this->internal['res_count'] == 0) { //perhaps No Results
$fullTable.= $this->pi_getLL('pi_list_noresults', 'No matches found.');
}
else {
// Adds the whole list table
$fullTable.=$this->pi_list_makelist($res);
// Adds the result browser after:
$fullTable.=$this->pi_list_browseresults(0);
}
// Returns the content from the plugin.
return $fullTable;
}
}
Aber es gibt keine ListView, die Ausgabe ist leer. Caching habe ich deaktiviert. Ich arbeite mit Typo3 4.2.1.
Hat jemand einen Tip für mich, wie ich weiterkomme?
Dank vorab und Gruß,
Tobias