|
|||
|
Hallo!
Ich besch?ftige mich gerade mit der xtc_show_category.inc.php Datei. Hier m?chte ich ein CSS-Men? integrieren. Beispiel: Code:
<ul>
<li>Kategorie 1
<ul>
<li>Kategorie 1.1
<ul>
<li>Kategorie 1.1.1</li>
</ul>
</li>
</ul>
</li>
<li>Kategorie 2
<ul>
<li>Kategorie 2.1</li>
</ul>
</li>
<li>Kategorie 3 </li>
</ul>
Da ich mich in PHP nicht sehr gut auskenne, wollte ich fragen ob es soetwas schon irgendwo gibt oder ob mir jemand dabei helfen k?nnte das umzusetzen. Was ich bisher geschafft habe (ist syntaktisch beim HTML-Output nicht ganz korrekt): Code:
<?php
function xtc_show_category($counter) {
global $foo, $categories_string, $id;
// image for first level
$img_1='';
for ($a=0; $a<$foo[$counter]['level']; $a++) {
if ($foo[$counter]['level']=='1') {
$categories_string .= '';
}
$categories_string .= '<ul>';
}
if ($foo[$counter]['level']=='') {
if (strlen($categories_string)=='0') {
$categories_string .='<ul>';
} else {
$categories_string .='</ul><ul>';
}
$categories_string .= $img_1;
$categories_string .= '<li><a href="';
} else {
$categories_string .= '<li><a href="';
}
if ($foo[$counter]['parent'] == 0) {
$cPath_new = 'cPath=' . $counter;
} else {
$cPath_new = 'cPath=' . $foo[$counter]['path'];
}
if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') $cPath_new.='&category='.xtc_cleanName($foo[$counter]['name']);
$categories_string .= xtc_href_link(FILENAME_DEFAULT, $cPath_new);
$categories_string .= '">';
if ( ($id) && (in_array($counter, $id)) ) {
$categories_string .= '';
}
// display category name
$categories_string .= $foo[$counter]['name'];
if ( ($id) && (in_array($counter, $id)) ) {
$categories_string .= '';
}
if (xtc_has_category_subcategories($counter)) {
$categories_string .= '';
}
if ($foo[$counter]['level']=='') {
$categories_string .= '</a></li>';
} else {
$categories_string .= '</a></li></ul>';
}
if (SHOW_COUNTS == 'true') {
$products_in_category = xtc_count_products_in_category($counter);
if ($products_in_category > 0) {
$categories_string .= ''; //'(' . $products_in_category . ')';
}
}
$categories_string .= '';
if ($foo[$counter]['next_id']) {
xtc_show_category($foo[$counter]['next_id']);
} else {
$categories_string .= '</ul>';
}
}
?>
|
|
|||
|
ich bin auch daran interessiert.... :bounce: :bounce: :bounce: ich habe an verschiedene stellen verschiedene zeichen gesetzt damit ich sehen k?nnte wie meine aenderungen auswirken. so war meine primitive art rauszubekommen.richtig gelungen hats mir auch nicht.
|
|
|||
|
Die Idee mit den Zeichen habe ich auch verfolgt, habe daf?r die Zeilennummer im PHP-Code genommen, so konnte ich feststellen wann welche Zeile aufgerufen wird.
Jedoch habe ich festgestellt, dass das momentane Men? nicht flexibel genug ist um so ein CSS-Men? korrekt umzusetzen. Solange keine L?sung sich finden l?sst, werde ich notgedrungen ein Table-Men? erstellen :cry: Bin n?mlich gerade dabei das gesamte XHTML-Template in CSS umzusetzen und ein Table-Men? mittendrin macht sich nicht gerade professionell. |
|
||||
|
ich habe es bei mir damals so gel?st:
Code:
<?php /* ----------------------------------------------------------------------------------------- $Id: xtc_show_category.inc.php,v 1.1 2004/04/26 20:26:42 fanta2k Exp $ XT-Commerce - community made shopping http://www.xt-commerce.com Copyright (c) 2003 XT-Commerce ----------------------------------------------------------------------------------------- based on: (c) 2000-2001 The Exchange Project (earlier name of osCommerce) (c) 2002-2003 osCommerce(categories.php,v 1.23 2002/11/12); www.oscommerce.com (c) 2003 nextcommerce (xtc_show_category.inc.php,v 1.4 2003/08/13); www.nextcommerce.org Released under the GNU General Public License ---------------------------------------------------------------------------------------*/ function xtc_show_category($counter) { global $foo, $categories_string, $id; // image for first level $img_1='<img src="templates/'.CURRENT_TEMPLATE.'/img/icon_arrow.jpg" alt="" />'; for ($a=0; $a<$foo[$counter]['level']; $a++) { if ($foo[$counter]['level']=='1') { $categories_string .= ""; } $categories_string .= ""; } if ($foo[$counter]['level']=='') { if (strlen($categories_string)=='0') { $categories_string .='<ul id="navlist">'; } $categories_string .= '<il><b><a href="'; } else { $categories_string .= '<il><a href="'; } if ($foo[$counter]['parent'] == 0) { $cPath_new = 'cPath=' . $counter; } else { $cPath_new = 'cPath=' . $foo[$counter]['path']; } if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') $cPath_new.='&category='.xtc_cleanName($foo[$counter]['name']); $categories_string .= xtc_href_link(FILENAME_DEFAULT, $cPath_new); $categories_string .= '">'; if ( ($id) && (in_array($counter, $id)) ) { $categories_string .= '<b>'; } // display category name $categories_string .= $foo[$counter]['name']; if ( ($id) && (in_array($counter, $id)) ) { $categories_string .= '</b>'; } if (xtc_has_category_subcategories($counter)) { $categories_string .= ''; } if ($foo[$counter]['level']=='') { $categories_string .= '</a></b></il>'; } else { $categories_string .= '</a></il>'; } if (SHOW_COUNTS == 'true') { $products_in_category = xtc_count_products_in_category($counter); if ($products_in_category > 0) { $categories_string .= '(' . $products_in_category . ')'; } } if ($foo[$counter]['next_id']) { xtc_show_category($foo[$counter]['next_id']); } else { $categories_string .= '</ul>'; } } ?> |
|
|||
|
Hierbei kommt aber kein syntaktisch korrektes HTML heraus:
Code:
<ul><li>Kat 1</li><li>Kat 1.1</li><li>Kat. 2</li></ul> N?chstes Problem w?re zu pr?fen, wenn eine Unterkategorie auftaucht, die Eltern-kategorie nicht mit direkt zu schliessen, sondern erst am Ende der Kinderkategorie. Beispiel 1 (richtig): Code:
<ul> <li>Kategorie 1 <ul> <li>Kategorie 1.1</li> </ul> </li> <li>Kategorie 2</li> </ul> Code:
<ul> <li>Kategorie 1</li> <ul> <li>Kategorie 1.1</li> </ul> <li>Kategorie 2</li> </ul> |
|
||||
|
Code:
<?php /* ----------------------------------------------------------------------------------------- $Id: xtc_show_category.inc.php 1262 2005-09-30 10:00:32Z mz $ XT-Commerce - community made shopping http://www.xt-commerce.com Copyright (c) 2003 XT-Commerce ----------------------------------------------------------------------------------------- based on: (c) 2000-2001 The Exchange Project (earlier name of osCommerce) (c) 2002-2003 osCommerce(categories.php,v 1.23 2002/11/12); www.oscommerce.com (c) 2003 nextcommerce (xtc_show_category.inc.php,v 1.4 2003/08/13); www.nextcommerce.org Released under the GNU General Public License list-style version by toro@toro-net.com ---------------------------------------------------------------------------------------*/ function xtc_show_category2($counter, $prev_counter) { global $foo, $categories_string, $id; if (strlen($categories_string)=='0') { $categories_string .='<ul class="cat_level_'.$foo[$counter]['level'].'"><li>'; } else { if ($foo[$counter]['level'] > $foo[$prev_counter]['level']) { $categories_string .= '<ul class="cat_level_'.$foo[$counter]['level'].'"><li>'; } elseif ($foo[$counter]['level'] == $foo[$prev_counter]['level']) { $categories_string .= '</li><li>'; } elseif ($foo[$counter]['level'] < $foo[$prev_counter]['level']) { $curr_level = $foo[$prev_counter]['level']; while ($foo[$counter]['level'] < $curr_level) { $categories_string .= '</li></ul>'; $curr_level--; } $categories_string .= '</li><li>'; } } $categories_string .= "\n"; $categories_string .= '<a href="'; $cPath_new=xtc_category_link($counter,$foo[$counter]['name']); $categories_string .= xtc_href_link(FILENAME_DEFAULT, $cPath_new); $categories_string .= '">'; if ( ($id) && (in_array($counter, $id)) ) { $categories_string .= ''; } // display category name $categories_string .= $foo[$counter]['name']; if ( ($id) && (in_array($counter, $id)) ) { $categories_string .= ''; } $categories_string .= '</a>'; if (SHOW_COUNTS == 'true') { $products_in_category = xtc_count_products_in_category($counter); if ($products_in_category > 0) { $categories_string .= '(' . $products_in_category . ')'; } } if ($foo[$counter]['next_id']) { xtc_show_category2($foo[$counter]['next_id'], $counter); } else { if ($foo[$counter]['level'] > 0 ) { $curr_level = $foo[$counter]['level']; while ($curr_level > 0 ) { $categories_string .= '</li></ul>'; $curr_level--; } } $categories_string .= '</li></ul>'; } } function xtc_show_category($counter) { xtc_show_category2($counter, 0); } ?> Gefunden unter: Link zum Thread |
|
||||
|
hier gibt es auch eine sch?ne l?sung:
http://www.xt-commerce.com/forums/index.ph...ndpost&p=158687 |
![]() |
| Lesezeichen |
| Stichworte |
| cssmen, xtcshowcategoryincphp |
| Themen-Optionen | |
| Ansicht | |
|
|