Kategorienmenu mit nsb_cat2menu
| Autor | Nachricht |
|---|---|
|
Verfasst am: 02. 01. 2006 [13:24]
|
|
|
hoppefamily
Themenersteller
Dabei seit: 03.04.2005
Beiträge: 130
|
Hallo, komme mit dieser Extension nicht weiter. Ich habe folgendes templat erstellt und ein gebunden: Setup: TYPOSCRIPT 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: HTML Was habe ich falsch gemacht? Gruss
Michael Hoppe |
|
Verfasst am: 02. 01. 2006 [14:16]
|
|
|
Flink
Dabei seit: 17.12.2003
Beiträge: 1661
|
hoppefamily schrieb: TYPOSCRIPT #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. WJT goes on...
Nightfever in Köln |
|
Verfasst am: 03. 01. 2006 [10:08]
|
|
|
Flink
Dabei seit: 17.12.2003
Beiträge: 1661
|
Hier das Beispiel aus der tt_products Newslist: TYPOSCRIPT 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? WJT goes on...
Nightfever in Köln |
|
Verfasst am: 03. 01. 2006 [10:40]
|
|
|
hoppefamily
Themenersteller
Dabei seit: 03.04.2005
Beiträge: 130
|
Ich habe obiges Beispiel noch ein wenig erweitert: TYPOSCRIPT 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: HTML <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: [url] http://mysite.de/index.php?id=46&no_cache=1&tx_ttproducts_pi1[cat]=6 [/url] 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. Gruss
Michael Hoppe |
|
Verfasst am: 05. 01. 2006 [16:40]
|
|
|
hoppefamily
Themenersteller
Dabei seit: 03.04.2005
Beiträge: 130
|
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. Gruss
Michael Hoppe |
|
Verfasst am: 05. 01. 2006 [17:56]
|
|
|
Flink
Dabei seit: 17.12.2003
Beiträge: 1661
|
hoppefamily schrieb: tt_products ist damit fast auf dem Level von oscommerce. Prima! WJT goes on...
Nightfever in Köln |
|
Verfasst am: 18. 01. 2006 [12:30]
|
|
|
Bernard
Dabei seit: 21.08.2002
Beiträge: 55
|
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 [Dieser Beitrag wurde 1mal bearbeitet, zuletzt am 18.01.2006 um 12:30.] |
|
Verfasst am: 18. 01. 2006 [13:17]
|
|
|
hoppefamily
Themenersteller
Dabei seit: 03.04.2005
Beiträge: 130
|
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 <?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']); } ?> [Dieser Beitrag wurde 1mal bearbeitet, zuletzt am 18.01.2006 um 13:19.] Gruss
Michael Hoppe |
|
Verfasst am: 18. 01. 2006 [18:55]
|
|
|
Bernard
Dabei seit: 21.08.2002
Beiträge: 55
|
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 |
|
Verfasst am: 18. 01. 2006 [19:23]
|
|
|
Bernard
Dabei seit: 21.08.2002
Beiträge: 55
|
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 [Dieser Beitrag wurde 1mal bearbeitet, zuletzt am 18.01.2006 um 21:49.] |



