[TYPO3-german] Seitenweise blättern? Ich raff es nicht!

marko.hoffmann at yes-globushaus.de marko.hoffmann at yes-globushaus.de
Thu Sep 14 11:38:08 CEST 2006


Hallo Leute,

da ich ja nun seit geraumer Zeit an meiner ersten Extensions hänge, habe ich nun ein Problem woran ich nun schon seit einer Woche arbeite.

Ich möchte in "listView" meine Suchergebnisse anzeigen lassen. Immer nur 25 Stück und unbegrenzte Anzahl von Seiten.
Leider habe ich überhaupt keine Ahnung wie ich das hinbekommen soll. Ich habe hier mal noch ein paar Auszüge aus meiner Klasse, vielleicht hat jemand von Euch den entscheidenen Tipp für mich.

Besten Dank
Marko

function main($content,$conf) {
	$this->conf=$conf;
	$this->pi_setPiVarDefaults();
	$this->pi_loadLL();
	
	// Preconfigure 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;
    $this->typolink_conf["additionalParams"] =
		$this->cObj->stdWrap($this->typolink_conf["additionalParams"],
		$this->typolink_conf["additionalParams."]);
    unset($this->typolink_conf["additionalParams."]);

    // Configure caching
    $this->allowCaching = $this->conf["allowCaching"]?1:0;
    if (!$this->allowCaching) {
		$GLOBALS["TSFE"]->set_no_cache();
	}
	
	$this->templateCode = $this->cObj->fileResource($this->conf["templateFile"]);
	
	if (isset($this->piVars['showUid']) && $this->piVars['showUid']) {
		$result = 'showUid';
	} elseif (isset($this->piVars['addUid']) && $this->piVars['addUid']) {
		$result = 'addUid';
	} else {
		$result = $this->createListView();
	}
	
	return $this->pi_wrapInBaseClass($result);
}

function createListView() {
	$content = '';
	$lconf = $this->conf["listView."];
	
	$this->internal['currentTable'] = 'tx_yesimmobilien_immobilien';
	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,3);		// 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['orderByList']='uid,objektnr,maklerobjektnr,anbieternr,objekttitel';

	// Bereich des Templates definieren
	$template = $this->cObj->getSubpart($this->templateCode,"###listVIEW###");
	
	// Definiere Array für Marker
	$markerArray = array();	
	
	// Definiere Array für wrappedSubparts
	$wrappedSubpartArray = array();
	
	// Lese alle Datensätze aus und speichere diese in $rows
	$rows = $this->getItems();
	
	// Alle ausgelesene Daten in Template schreibem
	while(list($c,$row) = each($rows)) {
		
		$expose_conf = $this->typolink_conf;
		$expose_conf["ATagParams"] = 'class="TextLinkGrey"';
		$expose_conf["additionalParams"] .= "&tx_yesimmobilien_pi1[showUid]=".$row['uid'];
		$expose_conf["useCacheHash"] = $this->allowCaching;
		$expose_conf["no_cache"] = !$this->allowCaching;
		$expose_link = $this->local_cObj->typolink("Exposé", $expose_conf);
		
		$add_merken = $this->typolink_conf;
		$add_merken["ATagParams"] = 'class="TextLinkGrey"';
		$add_merken["additionalParams"] .= "&tx_yesimmobilien_pi1[addUid]=".$row['uid'];
		$add_merken["useCacheHash"] = $this->allowCaching;
		$add_merken["no_cache"] = !$this->allowCaching;
		$merken = $this->local_cObj->typolink("merken", $add_merken);
		
		$markerArray["###OBJEKTTITEL###"] = $row['objekttitel'];
		$markerArray["###EXPOSE###"] = $expose_link;
		$markerArray["###MERKEN###"] = $merken;
		$markerArray["###PREVNEXT###"] = $this->getPrevNext();
		$content .= $this->cObj->substituteMarkerArrayCached($template,$markerArray,array(),$wrappedSubpartArray);
	}
	
	// Debugausgabe
	return $content;
}

function getItems() {
	if(!isset($_REQUEST['offset'])) { $offset = 0; }
	else { $offset = (int) $_REQUEST['offset']; }
	
	$maxPage = '2';
	$startPage = '0';
	
	$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
		'*',
		$this->internal['currentTable'],
		$addWhere,
		'',
		'crdate DESC',
		''
	);

	$out = array();
	while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
		$out[] = $row;
	}
	return $out;
}




More information about the TYPO3-german mailing list