Zum Inhalt springen

Selectbox in Frontend sortieren

Erstellt am 7. Juli 2008 · 5 Antworten · letzte Antwort am 8. Juli 2008

Tags: Frage

wwt ·

Wie bekomme ich es hin, dass ich eine Selectbox auch im FE sortieren kann??

	function enterFEevent() {
	
			// get Categories:
		$this->cat = $this->validRows("tx_mjseventpro_cat", "title", 'cat');

gibt mir ja den title aus.

Ich brauch eaber etwas wie:

$res = mysql_query("SELECT 'title' FROM `tx_mjseventpro_cat` ORDER BY `uid` ASC;");

Wie kann ich das kombinieren??

Die Einstellungen in der TCA

"cat" => Array (		
			"exclude" => 1,		
			"label" => "LLL:EXT:mjseventpro/locallang_db.php:tx_mjseventpro.cat",		
			"config" => Array (
				"type" => "select",	
				"foreign_table" => "tx_mjseventpro_cat",	
				"foreign_table_where" => "ORDER BY uid",	
				"size" => 1,	
				"minitems" => 0,
				"maxitems" => 1,
				"items" => Array (
					Array("", 0),
				),
			)
		),

greifen nur im Backend.

wwt ·

Hallo Georg!
Ja schon, dann kann ich statt title z.b. uid ausgeben lassen. Das geht ja auch problemlos.

Ich brauche aber: Ausgabe "title", sortiert nach "uid".
Diese mysql_query bringe ich aber nicht hin.

Kannst Du mir bitte ein Beispiel geben?

just2b ·

ich kenne die ext nicht, aber wenn du schon dort drin herumcodedest, kannst du ja auch direkt statt der fkt deine eigene aufrufen

georg

wwt ·

...statt der fkt...?

Also für alle hier nochmals ausführlich:

Die ext heisst "MJS_eventpro" und ist für Events mit Frontend-editing. Leider seit Jahren nicht mehr weiterentwickelt worden. Habe sie aber trotzdem soweit sehr gut an meine Bedürfnisse anpassen können.

Im Wesentlichen geht es jetzt noch um die Datei "pi1/class.tx_mjseventpro_pi1.php" welche unter anderem dafür zuständig ist, dass die Kategorien ausgegeben werden. dies findet 3mal statt:

Das 1. Mal ca. Zeile 238 (hier Zeile 3):

// Adds the category selector box:
$markerArray['###CATEGORY_LABEL###'] = $this->pi_getLL("listFieldHeader_cat");
$markerArray['###CATEGORY_SELECT###'] = $this->htmlSelect("tx_mjseventpro_cat", "title", 'cat');

Das 2. Mal ca. Zeile 1045:

	/**
	 * Make the selectorbox with categories.
	 * $fNmm is the name of the field in the main table.
	 */
	function htmlSelect($table='', $fieldName='', $fNmm='') {
		$validRowsArray = $this->validRows($table, $fieldName, $fNmm);
		$selectedValue = $this->piVars[$fNmm];
		$opt = array();
		$opt[] = '<option value="'.
				htmlentities($this->pi_linkTP_keepPIvars_url('', $this->allowCaching))
				.'">alle</option>';
			// Show selectorbox only, if there are any categories.
		if($validRowsArray) {
			foreach ($validRowsArray as $uid => $title) {
				$opt[] = '<option value="'.
					htmlentities($this->pi_linkTP_keepPIvars_url(array("cat" => $uid), $this->allowCaching))
					.'"'.
					($selectedValue == $uid ? " SELECTED" : "")
					.'>'.
					htmlentities($title)
					.'</option>';
			}
			return '<select onChange="document.location=this.options[this.selectedIndex].value;">'.implode("", $opt).'</select>';
		}
		return '';
	} // htmlSelect

	/**
	 * Make the selectorbox with categories.
	 * $fNmm is the name of the field in the main table.
	 *
	 * @param string $table
	 * @param string $fieldName
	 * @param string $fNmm
	 * @return string
	 */
	function htmlSelect4input($table='', $fieldName='', $fNmm='') {
// Der Wert der Variablen  $table wird nie benutzt (Zeile 1081)
// Der Wert der Variablen  $fieldName wird nie benutzt (Zeile 1081)
		$validRowsArray = $this->$fNmm;
		$selectedValue = $this->piVars[$fNmm];
		$opt = array();
		$opt[] = '<option value="">-</option>';
			// Show selectorbox only, if there are any categories.
		if($validRowsArray) {
			foreach ($validRowsArray as $uid => $title) {
				$opt[] = '<option value="'.$uid.'"'.($selectedValue == $uid ? " SELECTED" : "").'>'.htmlentities($title).'</option>';
			}
			return '<select name="tx_mjseventpro_pi1['.$fNmm.']">'.implode("", $opt).'</select>';
		}
		return '';
	} // htmlSelect4input

Das 3. Mal ca. Zeile 1209, hier findet die Ausgabe der Datenbak im FE-Formular statt:

	function enterFEevent() {

			// get Categories:
		$this->cat = $this->validRows("tx_mjseventpro_cat", "title");

Mein Problem:
Überall wird "title" ausgegeben, was ich natürlich nach "uid" ändern kann. Dann habe ich aber nur die "uid" Nummer da stehen.

Ich brauch als Ausgabe den "title", aber sortiert nach "uid".
Und das ist die Entscheidende Frage:
Wie geht das?????
Wer hat einen Ansatz, die Datenbankausgabe zu sortieren?

wwt ·

Habs gelöst:

	function validRows($table, $fieldName) {
	// check this: pi_getCategoryTableContents()    !!!
		 $workaround = $this->piVars['sword'];
		 $this->piVars['sword'] = FALSE;
		//$res = $this->pi_exec_query($table,'','',0,'',$fieldName,'');
		    //Oben das ORIGINAL, Unten die neue Abfrage query 
                    //direkt in die tx_mjseventpro_cat
		$res = $this->pi_exec_query(tx_mjseventpro_cat);
		while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
                        //hier die definition in welcher Tabelle (='uid')
			$validRowsArray[$row['uid']] = $row[$fieldName];
		}
		$this->piVars['sword'] = $workaround;
		return $validRowsArray;
	} // validRows