Zum Inhalt springen

Kategorienmenu mit nsb_cat2menu

Erstellt am 2. Januar 2006 · 39 Antworten · letzte Antwort am 23. November 2011 · Seite 1 von 2

Tags: Frage

hoppefamily ·

Hallo,
komme mit dieser Extension nicht weiter.

Ich habe folgendes templat erstellt und ein gebunden:

Setup:

lib.tx_nsbcat2menu = HMENU
lib.tx_nsbcat2menu.special = userfunction
lib.tx_nsbcat2menu.special.userFunc = tx_nsbcat2menu_pi1->main

#category uid to display, comma separated. it's recursive
lib.tx_nsbcat2menu.special.catList=1

#uid of the page containing the category tree, comma separated	
lib.tx_nsbcat2menu.special.pidlist=46

#name of the category table
lib.tx_nsbcat2menu.special.catTable=tx_dam_cat

#name of the parent category in the category table	
lib.tx_nsbcat2menu.special.parentEntry=1

#name of the extension to trigger
lib.tx_nsbcat2menu.special.extTrigger=tx_nsbfedam_pi1

#variable name of the category in target extension
lib.tx_nsbcat2menu.special.varCat=cat

#the page uid containing the extention to display, keep commented for self targeting
#lib.tx_nsbcat2menu.special.targetId

#selecting a category adds all child category (recursive select) boolean
lib.tx_nsbcat2menu.special.recSel = TRUE


lib.tx_nsbcat2menu.1 = TMENU
lib.tx_nsbcat2menu.1 {
  noBlur = 1
  # Normal state properties
  NO.allWrap = <div class="cat-no"> | </div>
  NO.stdWrap.htmlSpecialChars = 1
  # Enable active state and set properties:
  ACT = 1
  ACT.stdWrap.htmlSpecialChars = 1
  ACT.allWrap = <div class="cat-act"> -> | </div>
}
lib.tx_nsbcat2menu.2 = TMENU
lib.tx_nsbcat2menu.2 < lib.tx_nsbcat2menu.1
lib.tx_nsbcat2menu.3 = TMENU
lib.tx_nsbcat2menu.3 < lib.tx_nsbcat2menu.1
lib.tx_nsbcat2menu.4 = TMENU
lib.tx_nsbcat2menu.4 < lib.tx_nsbcat2menu.1

page.5555 < lib.tx_nsbcat2menu

Es erscheint folgender Code auf der Seite:

  <div class="cat-no">
    <a href="index.php?id=46&amp;no_cache=1"></a>

  </div>

Was habe ich falsch gemacht?

Flink ·
hoppefamily schrieb
#name of the category table
lib.tx_nsbcat2menu.special.catTable=tx_dam_cat

Das ist für tt_products falsch. Hier muß tt_products_cat hinein.

Flink ·

Hier das Beispiel aus der tt_products Newslist:

lib.nsbcat2menu = HMENU
lib.nsbcat2menu.special = userfunction
lib.nsbcat2menu.special.userFunc = tx_nsbcat2menu_pi1->main

lib.nsbcat2menu.special.catList=5
#the uid of my root category, you can have more than one root exemple(catList=5,6)
lib.nsbcat2menu.special.pidlist=4
#the uid of the storage folder where my  categories are

lib.nsbcat2menu.special.catTable=tt_products_cat
lib.nsbcat2menu.special.parentEntry=parent_category
lib.nsbcat2menu.special.extTrigger=tx_ttproducts_pi1
lib.nsbcat2menu.special.varCat=cat

lib.nsbcat2menu.special.recSel = 1
#if true selecting a parent category selects all childs

lib.nsbcat2menu.1 = TMENU
lib.nsbcat2menu.1 {
  noBlur = 1
  # Normal state properties
  NO.allWrap = <div class="menu1-no"> | </div>
  NO.stdWrap.htmlSpecialChars = 1
  # Enable active state and set properties:
  ACT = 1
  ACT.stdWrap.htmlSpecialChars = 1
  ACT.allWrap = <div class="menu1-act"> -> | </div>
}
lib.nsbcat2menu.2 = TMENU
lib.nsbcat2menu.2 < lib.nsbcat2menu.1
lib.nsbcat2menu.3 = TMENU
lib.nsbcat2menu.3 < lib.nsbcat2menu.1
lib.nsbcat2menu.4 = TMENU
lib.nsbcat2menu.4 < lib.nsbcat2menu.1

Kann das mal jemand ausprobieren?

hoppefamily ·

Ich habe obiges Beispiel noch ein wenig erweitert:

lib.nsbcat2menu = HMENU
lib.nsbcat2menu.special = userfunction
lib.nsbcat2menu.special.userFunc = tx_nsbcat2menu_pi1->main
 
lib.nsbcat2menu.special.catList=6
#the uid of my root category, you can have more than one root exemple(catList=5,6)
lib.nsbcat2menu.special.pidlist=53
#the uid of the storage folder where my  categories are

lib.nsbcat2menu.special.catTable=tt_products_cat
lib.nsbcat2menu.special.parentEntry=parent_category
lib.nsbcat2menu.special.extTrigger=tx_ttproducts_pi1
lib.nsbcat2menu.special.varCat=cat

lib.nsbcat2menu.special.recSel = 0
#if true selecting a parent category selects all childs

lib.nsbcat2menu.1 = TMENU
lib.nsbcat2menu.1 {
  noBlur = 1
  # Normal state properties
  NO.allWrap = <div class="menu1-no"> | </div>
  NO.stdWrap.htmlSpecialChars = 1
  # Enable active state and set properties:
  ACT = 1
  ACT.stdWrap.htmlSpecialChars = 1
  ACT.allWrap = <div class="menu1-act"> -> | </div>
}
lib.nsbcat2menu.2 = TMENU
lib.nsbcat2menu.2 {
  noBlur = 1
  # Normal state properties
  NO.allWrap = <div class="menu2-no">-- | </div>
  NO.stdWrap.htmlSpecialChars = 1
  # Enable active state and set properties:
  ACT = 1
  ACT.stdWrap.htmlSpecialChars = 1
  ACT.allWrap = <div class="menu2-act">-- -> | </div>
}
lib.nsbcat2menu.3 = TMENU
lib.nsbcat2menu.3 {
  noBlur = 1
  # Normal state properties
  NO.allWrap = <div class="menu3-no">---- | </div>
  NO.stdWrap.htmlSpecialChars = 1
  # Enable active state and set properties:
  ACT = 1
  ACT.stdWrap.htmlSpecialChars = 1
  ACT.allWrap = <div class="menu3-act">---- -> | </div>
}
lib.nsbcat2menu.4 = TMENU
lib.nsbcat2menu.4 {
  noBlur = 1
  # Normal state properties
  NO.allWrap = <div class="menu4-no">------ | </div>
  NO.stdWrap.htmlSpecialChars = 1
  # Enable active state and set properties:
  ACT = 1
  ACT.stdWrap.htmlSpecialChars = 1
  ACT.allWrap = <div class="menu4-act">------ -> | </div>
}
lib.nsbcat2menu.2 = TMENU
lib.nsbcat2menu.2 < lib.nsbcat2menu.2
lib.nsbcat2menu.3 = TMENU
lib.nsbcat2menu.3 < lib.nsbcat2menu.3
lib.nsbcat2menu.4 = TMENU
lib.nsbcat2menu.4 < lib.nsbcat2menu.4 

page.5555 < lib.nsbcat2menu

Es ergibt folgenden HTML-Output, was auch meinen Erwartungen und meinem Kategoriebaum entspicht:

  <div class="menu1-no">
    <a href="index.php?id=46&no_cache=1&tx_ttproducts_pi1[cat]=6">Werkzeug</a>

  </div>

  <div class="menu2-no">
    --<a href="index.php?id=46&no_cache=1&tx_ttproducts_pi1[cat]=1">Bohrmaschinen</a>
  </div>

  <div class="menu3-no">
    ----<a href="index.php?id=46&no_cache=1&tx_ttproducts_pi1[cat]=5">große Bohrmaschinen</a>

  </div>

  <div class="menu2-no">
    --<a href="index.php?id=46&no_cache=1&tx_ttproducts_pi1[cat]=2">Hämmer</a>
  </div>

  <div class="menu3-no">
    ----<a href="index.php?id=46&no_cache=1&tx_ttproducts_pi1[cat]=3">kleine Hämmer</a>

  </div>

Es sieht dann so aus:

Werkzeug
--Bohrmaschinen
----große Bohrmaschinen
--Hämmer
----kleine Hämmer

Ein Click auf Werkzeug ergibt folgenden URL:

http://mysite.de/index.php?id=46&no_cache=1&tx_ttproducts_pi1[cat]=6

Nur wie bringe ich dies jetzt mit tt_products zusammen? Bzw. wie lasse ich in der Listview nur die Produkte der Kategorie anzeigen?

Ein weiterer Punkt ist das leider immer der ganze Kategoriebaum "aufgeblättert" wird. Besser wäre das nur die "rootline" der Kategorien "aufgeblättert" würde.

hoppefamily ·

Ich habe gar nichts falsch gemacht! Es funktioniert, hurra...

Ich habe die Extension 'nsbcat2menu' erweitert.
Den sourcecode habe ich in der Newsgroup gepostet.

Hier mein Beitrag in der Newsgroup:

Hi,
I have modified the extension 'nsb_cat2menu'.
1. It works now like a 'normal' menu. It shows only the categories in the
rootline. (and the second level)
2. 'lib.nsbcat2menu.special.catList=0' autogenerated the catlist from all
categories in pidlist where parent_category=0

The file 'class.tx_ttproducts_list_view.php' is attached.
Please mail me for any bugs.

--> I could not wait for these features ;-)

Michael Hoppe

Damit ist meiner Meinung nach tt_products jetzt vernünftig zu gebrauchen.
Es ist zwar kein Futuremonster, aber für einen normalen Shop reicht es.
tt_products ist damit fast auf dem Level von oscommerce.

Bernard ·
hoppefamily schrieb

Ich habe die Extension 'nsbcat2menu' erweitert.
Den sourcecode habe ich in der Newsgroup gepostet.

Hi hoppefamily,

hast Du den Sourcecode von class.tx_ttproducts_list_view.php in der Newsgroup gepostet? Ich finde dort nichts.

Was hast Du in class.tx_ttproducts_list_view.php denn verändert? Könntest Du das hier noch einmal posten.

Vielen Dank,

Bernard

hoppefamily ·

Leider hatte ich mich verschrieben. Die Datei heist natürlich: "tx_nsbcat2menu_pi1.php".
Einfach die Extension installieren und die Datei austauschen.

Der Thread heist "[Typo3-shop] to browse categories in FE" vom 6.12.

Hier die Datei:

<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2005 Sami Ben-yahia (sittinggoat@hotmail.com)
*  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!
***************************************************************/
/**
 * Plugin 'cat2menu' for the 'nsb_cat2menu' extension.
 *
 * @author	Sami Ben-yahia <sittinggoat@hotmail.com>
 */
  // modified by Michael Hoppe <michael@hoppefamily.de>


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

class tx_nsbcat2menu_pi1 extends tslib_pibase {
//	var $prefixId = 'tx_nsbcat2menu_pi1';		// Same as class name (used only by pivars ?)
	var $scriptRelPath = 'pi1/class.tx_nsbcat2menu_pi1.php';	// Path to this script relative to the extension dir.
	var $extKey = 'nsb_cat2menu';	// The extension key.
//i must think
	var $pi_checkCHash = TRUE;
	var $internal = Array(		// Used internally for general storage of values between methods
		'catArr' => Array(),		//Current category table from pi_getCategoryTableContents
		'recSelReg' => ''	//Used only if the recursive select option is on (recursiveSelectionRegistry)
	);

	function main($content,$conf){
		$this->conf=$conf;
//i don't expect side effects	
		$this->prefixId = $this->conf['extTrigger'];
		$my_vars = $GLOBALS["TSFE"]->fe_user->getKey('ses','nsb_cat2menu');
		$tmpAct = t3lib_div::_GET($this->prefixId);
		$tmpAct = t3lib_div::intExplode(",",$tmpAct['cat']);
		if(0){		
//		if(isset($my_vars[$this->prefixId])){
			$menuArray=$my_vars[$this->prefixId];
			$this->markActive($menuArray,$tmpAct);
		}else{
			$this->conf['targetId']=$this->conf['targetId']?$this->conf['targetId']:0;
			$table=$this->conf['catTable'];
			$pid=$this->conf['pidlist'];
//get the whole autorized category table, the tree will be constructed later in php with makeMenuArray($rootLine)
			$whereClause='';
			$orderBy='';
			$limit='';
			$this->internal['catArr']=$this->pi_getCategoryTableContents($table,$pid,$whereClause,$groupBy,$orderBy,$limit);
//mark active for no cookie client config
			while(current($tmpAct)){
				$this->internal['catArr'][current($tmpAct)]['ITEM_STATE']='ACT';
				next($tmpAct);
			}
			$menuArray=$this->makeMenuArray(t3lib_div::intExplode(",",$this->conf['catList']));
//this session storage alows different multiple instances only if the triggered extension is different
			$my_vars[$this->prefixId]=$menuArray;
			$GLOBALS["TSFE"]->fe_user->setKey('ses','nsb_cat2menu',$my_vars);
		}
		$retvar1 = $this->lightenMenu($menuArray);
		return $retvar1;
	}
//used by the session menuArray	
	function markActive(&$menuArray,$actCatArr){
		while(current($actCatArr)){
			reset($menuArray);
			while (list($key, $val) = each($menuArray)) {
				if(current($actCatArr)==$menuArray[$key]['uid']){
					$menuArray[$key]['ITEM_STATE']='ACT';
				}
				if($menuArray[$key]['_SUB_MENU']){
					$this->markActive($menuArray[$key]['_SUB_MENU'],$actCatArr);
				}
			}
			next($actCatArr);
		}
	}
//currently will get all the branches from the category 'rootline' no recursive level option
	function makeMenuArray($rootLine){
		//autodetect catList
		if($rootLine[0] == 0) {
			$i=0;
			foreach($this->internal['catArr'] as $t){
				if($t['parent_category'] == '0') {
					$rootLine[$i] = $t['uid'] + 0;
					$i++;
				}
		  }
		}
		foreach($rootLine as $k => $v){
			$menuArray[$k]=$this->internal['catArr'][$v];
			$this->getHref($menuArray[$k]);
			$this->makeSubMenu($menuArray[$k], '1');
		}
		return $menuArray;
	}
	function makeSubMenu(&$menuArray,$act){
		foreach($this->internal['catArr'] as $v){
			if($menuArray['uid']==$v[$this->conf['parentEntry']]){
				$this->getHref($v);
			  if($v[ITEM_STATE] == 'ACT') {
			  	$v[ROOTLINE] = TRUE;
			  	$ret = '1';
			  }
			  else {
			    $ret = '0';	
			  }
				$retc = $this->makeSubMenu($v, $ret);
			  if($retc) {
			  	$v[ROOTLINE] = TRUE;
			  }
			  if($retc OR $ret OR ($act=='1')) {
				  $menuArray['_SUB_MENU'][]=$v;
				}
			}
		}
		return $ret;
	}
	
	function getHref(&$menuArray){
		if($this->conf['recSel']){
			$this->internal['recSelreg']=$menuArray['uid'];
			$this->getRecHref($menuArray);
//TODO this->conf['varHasCHash']			
			$menuArray['_OVERRIDE_HREF'] = $this->pi_linkTP_keepPIvars_url(array($this->conf['varCat'] => $this->internal['recSelreg']),0,0,$this->conf['targetId']);
		}else{
			$menuArray['_OVERRIDE_HREF'] = $this->pi_linkTP_keepPIvars_url(array($this->conf['varCat'] => $menuArray['uid']),0,0,$this->conf['targetId']);
		}
	}
	function getRecHref($menuArray){
		foreach($this->internal['catArr'] as $v){
			if($menuArray['uid']==$v[$this->conf['parentEntry']]){
				$this->internal['recSelreg'].=','.$v['uid'];
				$this->getRecHref($v);
			}
		}
	}
//used to avoid side effects by removing unecessary keys
	function lightenMenu($menuArray){
		$root = FALSE;
		while (list($key, $val) = each($menuArray)) {
			$lightMenuArray[$key]['title']=$menuArray[$key]['title'];
			$lightMenuArray[$key]['_OVERRIDE_HREF']=$menuArray[$key]['_OVERRIDE_HREF'];
			$lightMenuArray[$key]['ITEM_STATE']=$menuArray[$key]['ITEM_STATE'];
  		if($menuArray[$key]['_SUB_MENU']){
	  		$this->lightenSubMenu($lightMenuArray[$key]['_SUB_MENU'],$menuArray[$key]['_SUB_MENU']);
		  }
		}
		return $lightMenuArray;
	}
	function lightenSubMenu(&$lightMenuArray,$menuArray){
		while (list($key, $val) = each($menuArray)) {
			$lightMenuArray[$key]['title']=$menuArray[$key]['title'];
			$lightMenuArray[$key]['_OVERRIDE_HREF']=$menuArray[$key]['_OVERRIDE_HREF'];
			$lightMenuArray[$key]['ITEM_STATE']=$menuArray[$key]['ITEM_STATE'];
			if($menuArray[$key]['_SUB_MENU']){
				$this->lightenSubMenu($lightMenuArray[$key]['_SUB_MENU'],$menuArray[$key]['_SUB_MENU']);
			}
		}
	}	
}



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

?>
Bernard ·

Hallo Hoppefamily,

vielen Dank für den Sourcecode. Bei mir funktioniert die Extension jetzt auch zu meiner Zufriedenheit.

Legst Du eigentlich alle Produkte in einem Sysordner ab oder hast du sie auf mehrere Sysordner verteilt.

Gruß

Bernard

Bernard ·

Leider zu früh gefreut.

Wenn ich von der Einzelsicht zurück in die Listenansicht komme, werden alle Produkte, also auch die, die nicht zu der jeweiligen Kategorie gehören, angezeigt.

Ähnlich verhält es sich bei limitierte Artikelanzeige pro Seite mit den Browselinks (Marker ###LINK_PREV### und ###LINK_NEXT###) in der Listenansicht. Beim Klick z.b. auf LINK_NEXT fliegt man aus der Kategorie raus und blättert wieder alle Artikel durch.

Gibt es für dieses Problem schon eine Lösung?

Danke,

Bernard

hoppefamily ·

Oh ja, hatte ich noch gar nicht bemerkt. Soweit bin ich mit meinem Shop noch nicht.

Dies liegt aber nicht an der Extension "nsbcat2menu" sondern an "tt_products".

Der GET-Parameter "tx_ttproducts_pi1[cat]=x" wird nicht mit "durchgezogen", sondern verworfen.

Dies geht nur durch Modifikation von tt_products zu beheben.

club-basic ·

Hallo

Ich habe mir Ihr Script angesehen und das orginal aus tx_nsbcat2menu_pi1.php mit dem ihrem ausgetauscht. Auch habe ich ihr typoscript in das setupfeld eingebaut.

Es wird mir nun zwar die kategorien als navigation angezeigt nur werden auf den klick ( index.php?id=63&no_cache=1&tx_ttproducts_pi1[cat]=57 )
alle produkte angezeigt. 57 ist auch die richtige id der aktegorie und 63 ist die site shop3

lib.nsbcat2menu.special.catList=0 # bei o werden alle kategorie angezeigt
#the uid of my root category, you can have more than one root exemple(catList=5,6)
lib.nsbcat2menu.special.pidlist=64 ' die ID des sysfoders in dem die Produkte sind
#the uid of the storage folder where my  categories are

typoscript habe ich hier eingebaut
shop3 hier habe ich das plugin shop mit liste eingebaut
---warenkorb
---kasse
---
---
---article (Sysfolder)

ich denke das der fehler zum einen an pidlist und catList liegt zum anderen an der einbindung des typoscripts im template shop und hier die einbindung der shopextension durch liste.

vieleicht habe sie ja eine ahnung und können mir hier weiter helfen.

gruss
r.b.

hoppefamily ·

So direkt fällt mir kein Fehler auf. Der Link sieht korrekt auf.
Der Fehler muss irgendwo in der eigentlichen Konfiguration von tt_products liegen.
tx_nsbcat2menu_pi1.php macht ja nichts anderen als den Link zu erzeugen.

Wen man tt_products (die Siete mit der Listview) alleine (ohne auch nur tx_nsbcat2menu_pi1.php installiert zu haben) mit dem Link aufruft sollte es auch funktionieren.
&tx_ttproducts_pi1[cat]=57 im Link schränkt die Listview auf die Kategorie ein.

Bevor Sie abe weitersuchen... Wenn man zu Singleview geht und zurück kommt wird &tx_ttproducts_pi1[cat]=57 aus dem Link gelöscht und damit alle Kategorien angezeigt. -> siehe weiter vorher in diesem Thread. Ich werde daher demnächst wieder auf "normale" Kategorien über Seiten zurückkehren. Bzw. auf die tt_commerce wechseln, wenn sie denn mal herauskommt.

Flink ·
hoppefamily schrieb

So direkt fällt mir kein Fehler auf. Der Link sieht korrekt auf.
Der Fehler muss irgendwo in der eigentlichen Konfiguration von tt_products liegen.
tx_nsbcat2menu_pi1.php macht ja nichts anderen als den Link zu erzeugen.

Dazu muß tt_products/lib/class.tx_ttproducts_marker.php korrigiert werden.

function getLinkParams($excludeList='',$addQueryString=array()) {
...
	$this->addQueryStringParam($queryString, 'cat');
...
FaBig ·
Flink schrieb

Dazu muß tt_products/lib/class.tx_ttproducts_marker.php korrigiert werden.

function getLinkParams($excludeList='',$addQueryString=array()) {
...
	$this->addQueryStringParam($queryString, 'cat');
...

Wie muss ich das anstellen? Wenn ich den Befehl einfüge, bekomme ich eine Fehlermeldung (Call to undefined function)! Gibt es diese Funktion erst ab 2.4.9 (ich verwende 2.4.8-)?

Als zweites wollte ich noch wissen was zu Teufel ich tun muss um die Kategorieliste angezeigt zu bekommen? Es funktioniert wenn ich das Bananaguard Template verwende bei meinem aber nicht!! Ich konnte im Bana-Template weder die bei der Darstellung verwendeten <ul> und <li> Elemente finden, noch etwas anderes Sigifikantes! Die Marker und Bereiche mit CATEGORY oder CAT im Namen habe ich in meinem Template ebenfalls.
Was genau muss in mein Template um die Kategorieliste darzustellen.

Grüße und Danke im Vorraus

Fabian

diegen ·

Besten Dank für die vielen aufschlussreichen Codebeispiele.
Ich habe eines bereits erfolgreich implementiert als Hauptmenü. Woran ich jetzt scheitere ist, ein Untermenü zu erstellen, welches nsb_cat2menu für Subkategorien implementiert.
Ich kann die beiden Menus leider nicht ins gleiche HMENU nehmen, da die beiden Menüs layouttechnisch voneinander getrennt sind.
Prinzipiell wäre dies auch kein Problem, da ich nur den Parameter catList auf die entsprechenden Subkategorien setzen müsste. Praktischerweise befinden sich diese gleich in der GET-Variable "tx_ttproducts_pi1[cat]", allerdings habe ich es bis anhin nicht geschafft, diese ins Template meines Submenüs zu integrieren. Hier mein Ansatz mit GPvar:

temp.catnavi = HMENU
temp.catnavi.special = userfunction
temp.catnavi.special.userFunc = tx_nsbcat2menu_pi1->main

temp.catnavi.special.catList = GPvar : tx_ttproducts_pi1 | cat
temp.catnavi.special.pidlist=71
temp.catnavi.special.catTable=tt_products_cat
temp.catnavi.special.parentEntry=parent_category
temp.catnavi.special.extTrigger=tx_ttproducts_pi1
temp.catnavi.special.varCat=cat
temp.catnavi.special.targetId = 2
temp.catnavi.special.recSel = 1
       
temp.catnavi.1 = TMENU
temp.catnavi.1{

    NO{
         wrapItemAndSub = <div class="navelement">|</div>
    }

}

Allerdings gibt er hier nichts aus (bis auf ein leeres Element (<div class="navelement">:<a href="index.php?id=2&no_cache=1" onfocus="blurLink(this);"></a></div>)). Wenn ich die catList manuell auf eine vorhandene Kategorie setzte, klappt es hingegen wunderbar...

Ist es irgendwie möglich, GET-Variabeln direkt in ein Template einzuspeisen (via Setup oder Constants)? Für jegliche Hinweise und Lösungsansatze bin ich sehr dankbar!

Beste Grüsse

Diego

diegen ·

Habe für mein Problem endlich eine lösung gefunden, falls es jemanden interessiert, hier ist sie:

Dazu muss die Extension nsb_cat2menu leicht modifiziert werden

$catList = $this->conf['catList'];
			if($catList==0){
			       $tx_ttproducts_pi1 = t3lib_div::GPvar("tx_ttproducts_pi1");
                               $catList = $tx_ttproducts_pi1["cat"];
			}
			$menuArray=$this->makeMenuArray(t3lib_div::intExplode(",",$catList));

Dieser code Muss anstelle der Zeile

$menuArray=$this->makeMenuArray(t3lib_div::intExplode(",",$this->conf['catList']));

eingetragen werden.

Dann kann im Template-Setup fürs Menü einfach die variable 'catList' auf 0 gesetzt werden und automatisch werden die entsprechenden Subkategorien (sofern im Obermenu 'recSel' aktiviert ist) weitergegeben.

Wem das alles zu kompliziert tönt und diese Anwendung so wirklich braucht, kann sich gerne bei mir melden!

Herzliche Grüsse

Diego

malisch01 ·
FaBig schrieb

Als zweites wollte ich noch wissen was zu Teufel ich tun muss um die Kategorieliste angezeigt zu bekommen? Es funktioniert wenn ich das Bananaguard Template verwende bei meinem aber nicht!! Ich konnte im Bana-Template weder die bei der Darstellung verwendeten <ul> und <li> Elemente finden, noch etwas anderes Sigifikantes! Die Marker und Bereiche mit CATEGORY oder CAT im Namen habe ich in meinem Template ebenfalls.
Was genau muss in mein Template um die Kategorieliste darzustellen.

Grüße und Danke im Vorraus

Fabian

Benutze auch das Bananaguard Template und die Kategorienliste(CATLIST) wird auch angezeigt.Kann aber den Marker im Bananaguard Template nicht finden.
Ich will über den CATLIST Subpart dann die Kategorienliste etwas anders darstellen. Gibt es hierzu noch eine andere Möglichkeit(mit wrap?)?

thanks in advance

malisch01 ·

:o
Tomaten vor den Augen? keine Ahnung wie ich es nicht finden konnte #paralyzed#

 <!-- ###ITEM_CATLIST_TEMPLATE### begin
	This subpart is used to display the regular list of categories.
	-->
semidark ·

Hallo zusammen,

erstmal danke für die vielen Anregungen im umgang mit dem nsb_cat2menu plugin.
Irgendwie gefiel mir das verhalten der daraus resultierenden menüs so gar nicht.
Es funktionierte einfach nicht so wie ich es von dem normalen menüs gewohnt war.

Darum habe ich die PHP Datei class.tx_nbscat2menu_pi1.php nocheinmal etwas überarbeitet so das jetzt ein "Aufklappbarer Kategorien Baum" möglich ist bei dem auch zwischen dem Menüstatus CUR und ACT unterschieden wird. Und das ganze noch, weil es so schön ist, als "Unsorted List" im TS Template konfiguriert.

Ich habe diese Anpassung bis jetzt nur ganz grob getestet und auch erst einmal im Einsatz. Naja und besonders ordentlich ist der Quellcode auch noch nicht.

hier für die Interessierten mein Template und die PHP Datei

lib.nsbcat2menu = HMENU
lib.nsbcat2menu.special = userfunction
lib.nsbcat2menu.special.userFunc = tx_nsbcat2menu_pi1->main

lib.nsbcat2menu.special.catList=0
lib.nsbcat2menu.special.pidlist=246

lib.nsbcat2menu.special.catTable=tt_products_cat
lib.nsbcat2menu.special.parentEntry=parent_category
lib.nsbcat2menu.special.extTrigger=tx_ttproducts_pi1
lib.nsbcat2menu.special.varCat=cat

lib.nsbcat2menu.special.targetId = 213
lib.nsbcat2menu.special.recSel = 0 #Funktionalität im PHP ausgeschaltet

lib.nsbcat2menu.1 = TMENU
lib.nsbcat2menu.1 {
	noBlur = 1
	expAll = 0
	NO = 1
	NO {
		ATagTitle.field = title
		ATagParams = id="main-menu"
		wrapItemAndSub = <li>|</li>|*|<li>|</li>|*|<li class="last">|</li>
	}
	ACT < .NO
	ACT.ATagParams = id="main-menu{elementUid}" class="active"
}

lib.nsbcat2menu.2 = TMENU
lib.nsbcat2menu.2 {
	wrap= <ul>|</ul>
	noBlur = 1
	expAll = 0
	NO = 1
	NO {
		ATagTitle.field = title
		ATagParams = id="main-menu"
		wrapItemAndSub = <li>|</li>|*|<li>|</li>|*|<li class="last">|</li>
	}
	CUR < .NO
	CUR.ATagParams = id="main-menu{elementUid}" class="active"	
}

lib.nsbcat2menu.3 = TMENU
lib.nsbcat2menu.3 < lib.nsbcat2menu.2
lib.nsbcat2menu.4 = TMENU
lib.nsbcat2menu.4 < lib.nsbcat2menu.2
<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2005 Sami Ben-yahia (sittinggoat@hotmail.com)
*  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!
***************************************************************/
/**
 * Plugin 'cat2menu' for the 'nsb_cat2menu' extension.
 *
 * @author      Sami Ben-yahia <sittinggoat@hotmail.com>
 */
  // modified by Nico Thomaier <nthomaier@creatible.com>


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

class tx_nsbcat2menu_pi1 extends tslib_pibase {
//      var $prefixId = 'tx_nsbcat2menu_pi1';  // Same as class name (used only by pivars ?)
        var $scriptRelPath = 'pi1/class.tx_nsbcat2menu_pi1.php';        // Path to this script relative to the extension dir.
        var $extKey = 'nsb_cat2menu';   // The extension key.
//i must think
        var $pi_checkCHash = TRUE;
        var $internal = Array(    // Used internally for general storage of values between methods
                'catArr' => Array(),        //Current category table from pi_getCategoryTableContents
                'recSelReg' => ''       //Used only if the recursive select option is on (recursiveSelectionRegistry)
        );

        function main($content,$conf){
                $this->conf=$conf;
//i don't expect side effects   
                $this->prefixId = $this->conf['extTrigger'];
                $my_vars = $GLOBALS["TSFE"]->fe_user->getKey('ses','nsb_cat2menu');
                
                $tmpAct = t3lib_div::_GET($this->prefixId);
                $tmpAct = t3lib_div::intExplode(",",$tmpAct['cat']);

                $this->conf['targetId']=$this->conf['targetId']?$this->conf['targetId']:0;
                $table=$this->conf['catTable'];
                $pid=$this->conf['pidlist'];
//get the whole autorized category table, the tree will be constructed later in php with makeMenuArray($rootLine)
                $whereClause='';
                $orderBy='';
                $limit='';
                $this->internal['catArr']=$this->pi_getCategoryTableContents($table,$pid,$whereClause,$groupBy,$orderBy,$limit);
//mark active or current for no cookie client config
                while(current($tmpAct)){
                        $this->internal['catArr'][current($tmpAct)]['ITEM_STATE']='ACT';
                        $this->internal['catArr'][]['ITEM_STATE']='ACT';
                        $parent = $this->internal['catArr'][current($tmpAct)]['parent_category'];
                        array_push($tmpAct,$parent);
                        if ($tmpAct[0]==current($tmpAct)) $this->internal['catArr'][current($tmpAct)]['ITEM_STATE']='CUR';
                        next($tmpAct);
                }
                $menuArray=$this->makeMenuArray(t3lib_div::intExplode(",",$this->conf['catList']));
//this session storage alows different multiple instances only if the triggered extension is different
                $my_vars[$this->prefixId]=$menuArray;
                $GLOBALS["TSFE"]->fe_user->setKey('ses','nsb_cat2menu',$my_vars);
                $retvar1 = $this->lightenMenu($menuArray);
                return $retvar1;
        }

//currently will get all the branches from the category 'rootline' no recursive level option
        function makeMenuArray($rootLine){
                //autodetect catList
                if($rootLine[0] == 0) {
                        $i=0;
                        foreach($this->internal['catArr'] as $t){
                                if($t['parent_category'] == '0') {
                                        $rootLine[$i] = $t['uid'] + 0;
                                        $i++;
                                }
                  }
                }
                foreach($rootLine as $k => $v){
                        $menuArray[$k]=$this->internal['catArr'][$v];
                        $this->getHref($menuArray[$k]);
						$act = 0;
						if ($menuArray[$k]['ITEM_STATE']=="ACT" || $menuArray[$k]['ITEM_STATE']=="CUR" ) $act = 1;
                        $this->makeSubMenu($menuArray[$k], $act);
                }
                return $menuArray;
        }
        function makeSubMenu(&$menuArray,$act){
                foreach($this->internal['catArr'] as $v){
                        if($menuArray['uid']==$v[$this->conf['parentEntry']]){
                                $this->getHref($v);
                          if($v['ITEM_STATE'] == 'ACT' || $v['ITEM_STATE'] == 'CUR') {
                                $v['ROOTLINE'] = TRUE;
                                $ret = '1';
                          }
                          else {
                            $ret = '0'; 
                          }
                                $retc = $this->makeSubMenu($v, $ret);
                          if($retc) {
                                $v['ROOTLINE'] = TRUE;
                          }
                          if($retc OR $ret OR ($act=='1')) {
                                  $menuArray['_SUB_MENU'][]=$v;
                                }
                        }
                }
                return $ret;
        }
       
        function getHref(&$menuArray){
                if(0) {
                // if($this->conf['recSel']){
                        $this->internal['recSelreg']=$menuArray['uid'];
                        $this->getRecHref($menuArray);
				// TODO this->conf['varHasCHash']
                        $menuArray['_OVERRIDE_HREF'] = $this->pi_linkTP_keepPIvars_url(array($this->conf['varCat'] => $this->internal['recSelreg']),0,0,$this->conf['targetId']);
                }else{
                        $menuArray['_OVERRIDE_HREF'] = $this->pi_linkTP_keepPIvars_url(array($this->conf['varCat'] => $menuArray['uid']),0,0,$this->conf['targetId']);
                }
        }
        function getRecHref($menuArray){
                foreach($this->internal['catArr'] as $v){
                        if($menuArray['uid']==$v[$this->conf['parentEntry']]){
                                $this->internal['recSelreg'].=','.$v['uid'];
                                $this->getRecHref($v);
                        }
                }
        }
//used to avoid side effects by removing unecessary keys
        function lightenMenu($menuArray){
                $root = FALSE;
                while (list($key, $val) = each($menuArray)) {
                        $lightMenuArray[$key]['title']=$menuArray[$key]['title'];
                        $lightMenuArray[$key]['_OVERRIDE_HREF']=$menuArray[$key]['_OVERRIDE_HREF'];
                        $lightMenuArray[$key]['ITEM_STATE']=$menuArray[$key]['ITEM_STATE'];
              if($menuArray[$key]['_SUB_MENU']){
                      $this->lightenSubMenu($lightMenuArray[$key]['_SUB_MENU'],$menuArray[$key]['_SUB_MENU']);
                  }
                }
                return $lightMenuArray;
        }
        function lightenSubMenu(&$lightMenuArray,$menuArray){
                while (list($key, $val) = each($menuArray)) {
                        $lightMenuArray[$key]['title']=$menuArray[$key]['title'];
                        $lightMenuArray[$key]['_OVERRIDE_HREF']=$menuArray[$key]['_OVERRIDE_HREF'];
                        $lightMenuArray[$key]['ITEM_STATE']=$menuArray[$key]['ITEM_STATE'];
                        if($menuArray[$key]['_SUB_MENU']){
                                $this->lightenSubMenu($lightMenuArray[$key]['_SUB_MENU'],$menuArray[$key]['_SUB_MENU']);
                        }
                }
        }       
}



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

?>

Ein live beispiel wird folgen sobald ich das mit meinem gewissen vereinen kann 😉

Gruß Semidark