Ñïèñîê òîâàðîâ â êàòåãîðèè ShopOS #
Íåìíîãî òåîðèè:
http://www.getinfo.ru/article610.html - êðóòàÿ ñòàòüÿ!
http://phpclub.ru/detail/article/db_tree
http://phpclub.ru/detail/article/db_tree
Ïî òîïèêó ïîíÿòíî, ÷òî îí ïîñâÿù¸í èìåííî äâèãó ShopOS. Êëàññíûé, â áåñïëàòíîé ñáîðêå îí èäåò áåç ïî÷òû (ôóíêöèÿ óìåëî óäàëåíà), íî èìåÿ ãóãë è ñíîðîâêó ìîæíî äîïèëèòü åãî, ÷òî áû îí çàðàáîòàë êàê ïîëíîôóíêöèîíàëüíûé ìàãàçèí÷èê. Äàëüøå î êàòåãîðèÿõ.
Äëÿ íà÷àëî íóæíî áûëî ïîëó÷èòü âîò òàêîå ìåíþ:
×òî áû ïðè íàæàòèè íà ãëàâíóþ êàòåãîðèþ âûïàäàë ñïèñîê òîâàðîâ. Íå äîëãî ìó÷àÿñü îòïèñàë íà îôèöèàëüíîì ôîðóìå . Óâû îòâåòîâ íå ïîëó÷èë, ãîòîâûõ ðåøåíèé íåò. Ïîíÿë, ÷òî ïðèä¸òñÿ ñàìîìó.
Ñ ×ÏÓ (âñòàâèòü â index.html âàøåãî øàáëîíà):
Íà âûõîäå:
Îêàçàëîñü ÷òî íåîáõîäèìîñòü â äàííîì ìåíþ îòïàäàåò, íî ïîÿâëÿåòñÿ íîâàÿ!
Êëàññ! Òåïåðü åñòü åùå óðîâåíü âëîæåííîñòè.
Ñ ×ÏÓ (âñòàâèòü â index.html âàøåãî øàáëîíà):
Íà âûõîäå:
Ìíå ×ÏÓ íå íàäî - ÁÅÇ ×ÏÓ (âñòàâèòü â index.html âàøåãî øàáëîíà):
";
} else { echo "";}
}
{/php}
Íà âûõîäå:
Ïîëó÷èëè ÷òî õîòåëè, íà íå ñîâñåì òàê. Òåïåðü ÿ íå ìîãó ïîïàñòü â ðàçäåë ÊÀÒÅÃÎÐÈÈ, îí òî íå êëèêàáåëüíûé (ÿ èñïîëüçóþ ÿâà ìåíþ ïðè êëèêå íà êàòåãîðèþ âûïàäàåò âëîæåííûé UL), à ýòî ñóùåñòâåííî è â ÒÇ ïðîïèñàíî.
Ïîýòîìó ýòîò âàðèàíò ìíå íå ïîäõîäèò, ñîâñåì. Áóäåì ðàáîòàòü ñ {$box_CATEGORIES}.
Èäåì â íàø_ñàéò\themes\íàø_øàáëîí\source\inc\show_category.inc.php. Ïðîâåðÿåì ÷òî áû ïàðàìåòð $MaxLevel ðàâåí áûë 1, ýòî çíà÷èò, ÷òî ïî óìîë÷àíèþ áóäåò ïîêàçûâàòüñÿ 1 óðîâåíü âëîæåííîñòè.
 òîì æå ôàéëèêå íàõîäèì:
if ($old_level > $level) {
è ïîñëå âñòàâëÿåì:
if ( isset($GLOBALS['cPath']) ) {
if ( !strpos($GLOBALS['cPath'], "_")===false ) {
$path = explode('_',$GLOBALS['cPath']);
$query = "SELECT * FROM
vip_products p,
vip_products_description pd,
vip_products_to_categories p2c,
vip_categories c
WHERE
c.categories_status='1'
and p.products_status = '1'
and p.products_id = p2c.products_id
and p.products_id=pd.products_id
and p2c.categories_id = '".$path[1]."'
and c.parent_id = '".$path[0]."'
ORDER by p.products_date_added";
$query = osDBquery($query);
$categories_string .= "
}
}
if ( !strpos($GLOBALS['cPath'], "_")===false ) {
$path = explode('_',$GLOBALS['cPath']);
$query = "SELECT * FROM
vip_products p,
vip_products_description pd,
vip_products_to_categories p2c,
vip_categories c
WHERE
c.categories_status='1'
and p.products_status = '1'
and p.products_id = p2c.products_id
and p.products_id=pd.products_id
and p2c.categories_id = '".$path[1]."'
and c.parent_id = '".$path[0]."'
ORDER by p.products_date_added";
$query = osDBquery($query);
$categories_string .= "
- ";
- ".$row1['products_name']." ";
while ($row1 = os_db_fetch_array($query)) {
$categories_string .= "
}
$categories_string .= "
}
}
Èòîãî: åñëè åñòü ïàðàìåòð cPath (îí ïîêàçûâàåò êàòåãîðèþ òåêóùóþ), òî ñìîòðèì âëîæåííàÿ îíà, åñëè äà, òî ðàçáèâàåì è ïîëó÷àåì àéäè êàòåãîðèè è ïîäêàòåãîðèè. À äàëüøå çàïðîñ - ðèñóåì ñïèñîê.
Òåïåðü, êîãäà âû íàæèìàåòå íà ïîäêàòåãîðèþ âûïàäàåò åùå è ñïèñîê òîâàðîâ. Îïòèìèçèðóéòå è êîâûðÿéòå -) Äà è íå çàáóäüòå â êîäå ïîìåíÿòü ïðåôèêñ ÁÄ íà ñâîé.
UPD 02.09.11. äëÿ åùå îäíîãî óðîâíÿ + îïòèìèçèðîâàí êîä.
âñòàâèòü â îðèãèíàëüíûé ôàéë show_category.inc.php ïîñëå ( $foo[$cid]['name'].$ProductsCount. ''; - 114 ñòðî÷êà)
if ($level == 3) {
if ( !empty($Aktiv)) {
//$categories_string .= $cid;
$query = "SELECT * FROM
vip_products_to_categories p2c,
vip_products p,
vip_products_description pd
WHERE
p2c.categories_id = '".$cid."'
and p.products_status = '1'
and p.products_id = p2c.products_id
and p.products_id=pd.products_id
ORDER by p.products_date_added";
$query = osDBquery($query);
$categories_string .= "
}
}
if ( !empty($Aktiv)) {
//$categories_string .= $cid;
$query = "SELECT * FROM
vip_products_to_categories p2c,
vip_products p,
vip_products_description pd
WHERE
p2c.categories_id = '".$cid."'
and p.products_status = '1'
and p.products_id = p2c.products_id
and p.products_id=pd.products_id
ORDER by p.products_date_added";
$query = osDBquery($query);
$categories_string .= "
- ";
while ($row1 = os_db_fetch_array($query)) {
$categories_string .= "[url=/product_info.php?products_id={$row1[]".$row1['products_name']."[/url]";
}
$categories_string .= "
}
}