Ñïèñîê òîâàðîâ â êàòåãîðèè ShopOS #

Ñïèñîê òîâàðîâ â êàòåãîðèè ShopOS

Íåìíîãî òåîðèè:
http://www.getinfo.ru/article610.html - êðóòàÿ ñòàòüÿ!
http://phpclub.ru/detail/article/db_tree

Ïî òîïèêó ïîíÿòíî, ÷òî îí ïîñâÿù¸í èìåííî äâèãó ShopOS. Êëàññíûé, â áåñïëàòíîé ñáîðêå îí èäåò áåç ïî÷òû (ôóíêöèÿ óìåëî óäàëåíà), íî èìåÿ ãóãë è ñíîðîâêó ìîæíî äîïèëèòü åãî, ÷òî áû îí çàðàáîòàë êàê ïîëíîôóíêöèîíàëüíûé ìàãàçèí÷èê. Äàëüøå î êàòåãîðèÿõ.

Äëÿ íà÷àëî íóæíî áûëî ïîëó÷èòü âîò òàêîå ìåíþ:
Ñïèñîê òîâàðîâ â êàòåãîðèè ShopOS

×òî áû ïðè íàæàòèè íà ãëàâíóþ êàòåãîðèþ âûïàäàë ñïèñîê òîâàðîâ. Íå äîëãî ìó÷àÿñü îòïèñàë íà îôèöèàëüíîì ôîðóìå . Óâû îòâåòîâ íå ïîëó÷èë, ãîòîâûõ ðåøåíèé íåò. Ïîíÿë, ÷òî ïðèä¸òñÿ ñàìîìó.

Ñ ×ÏÓ (âñòàâèòü â index.html âàøåãî øàáëîíà):

            {php}        
            $sql = "SELECT cat.categories_id, cd.categories_name FROM vip_categories cat, vip_categories_description cd WHERE cat.categories_status = '1' AND cd.categories_id = cat.categories_id";
            $sql = osDBquery($sql);
            while ($row = os_db_fetch_array($sql)) {
                    $menu[$row['categories_id']] = $row['categories_name'];
            }
            foreach ($menu as $CatId => $CatName )
            {
                echo "
  • ".$CatName."";
                echo "
      ";
                      $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 = '".$CatId."'
                          and c.categories_id = '".$CatId."'
                      ORDER by p.products_date_added";
                      $query = osDBquery($query);
                      while ($row1 = os_db_fetch_array($query)) {
                          echo "
    • ".$row1['products_name']."
    • ";
                      }
                  echo "
  • ";
            }
            {/php}            


Íà âûõîäå:


Îêàçàëîñü ÷òî íåîáõîäèìîñòü â äàííîì ìåíþ îòïàäàåò, íî ïîÿâëÿåòñÿ íîâàÿ!
Ñïèñîê òîâàðîâ â êàòåãîðèè ShopOS

Êëàññ! Òåïåðü åñòü åùå óðîâåíü âëîæåííîñòè.

Ñ ×ÏÓ (âñòàâèòü â index.html âàøåãî øàáëîíà):

    {php}
    $sql = "SELECT cat.categories_id, cat.parent_id, cat.categories_url, cd.categories_name FROM vip_categories cat, vip_categories_description cd WHERE cat.categories_status = '1' AND cd.categories_id = cat.categories_id ORDER BY cat.parent_id, cat.categories_id";
    $sql = osDBquery($sql);
    while ($row = os_db_fetch_array($sql)) {
            $menu[$row['parent_id']][$row['categories_id']] = $row['categories_name'];
    }
    foreach ($menu[0] as $CatId => $CatName )
    {
     echo "
  • ".$CatName."";
     if (isset($menu[$CatId])) {
            echo "
      ";
               foreach ($menu[$CatId] as $ItemId => $ItemName)
               {
                echo "
    • ".$ItemName."";
                echo "
        ";
                        $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 = '".$ItemId."'
                                and c.parent_id = '".$CatId."'
                        ORDER by p.products_date_added";
                        $query = osDBquery($query);
                        while ($row1 = os_db_fetch_array($query)) {
                                echo "
      • ".$row1['products_name']."
      • ";
                        }  
                   echo "
      ";
                echo "
    • ";
               }
              echo "
  • ";
     } else { echo "";}
    }
    {/php}


Íà âûõîäå:



Ìíå ×ÏÓ íå íàäî - ÁÅÇ ×ÏÓ (âñòàâèòü â index.html âàøåãî øàáëîíà):


    {php}
    $sql = "SELECT cat.categories_id, cat.parent_id, cat.categories_url, cd.categories_name FROM vip_categories cat, vip_categories_description cd WHERE cat.categories_status = '1' AND cd.categories_id = cat.categories_id ORDER BY cat.parent_id, cat.categories_id";
    $sql = osDBquery($sql);
    while ($row = os_db_fetch_array($sql)) {
            $menu[$row['parent_id']][$row['categories_id']] = $row['categories_name'];
    }
    foreach ($menu[0] as $CatId => $CatName )
    {
     echo "
  • ".$CatName."";
     if (isset($menu[$CatId])) {
            echo "
      ";
               foreach ($menu[$CatId] as $ItemId => $ItemName)
               {
                echo "
    • ".$ItemName."";
                echo "
        ";
                        $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 = '".$ItemId."'
                                and c.parent_id = '".$CatId."'
                        ORDER by p.products_date_added";
                        $query = osDBquery($query);
                        while ($row1 = os_db_fetch_array($query)) {
                                //echo "
        ";
                                //print_r($row1);
                                //echo "
        ";
                                echo "
      • ".$row1['products_name']."
      • ";
                        }  
                   echo "
      ";
                echo "
    • ";
               }
              echo "
  • ";
     } 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 .= "
    ";
                                    while ($row1 = os_db_fetch_array($query)) {
                                        $categories_string .= "
  • ".$row1['products_name']."
  • ";
                                    }      
                                    $categories_string .= "
";
                            }
                        }

Èòîãî: åñëè åñòü ïàðàìåòð cPath (îí ïîêàçûâàåò êàòåãîðèþ òåêóùóþ), òî ñìîòðèì âëîæåííàÿ îíà, åñëè äà, òî ðàçáèâàåì è ïîëó÷àåì àéäè êàòåãîðèè è ïîäêàòåãîðèè. À äàëüøå çàïðîñ - ðèñóåì ñïèñîê.
Ñïèñîê òîâàðîâ â êàòåãîðèè ShopOS

Òåïåðü, êîãäà âû íàæèìàåòå íà ïîäêàòåãîðèþ âûïàäàåò åùå è ñïèñîê òîâàðîâ. Îïòèìèçèðóéòå è êîâûðÿéòå -) Äà è íå çàáóäüòå â êîäå ïîìåíÿòü ïðåôèêñ ÁÄ íà ñâîé.

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 .= "
    ";
                                    while ($row1 = os_db_fetch_array($query)) {
                                        $categories_string .= "
  • [url=/product_info.php?products_id={$row1[]".$row1['products_name']."[/url]";
                                    }      
                                    $categories_string .= "
";
                            }
                        }

Àÿêñ ÷àò - MYSQL PHP JQUERY CSS3 XHTML #

Àÿêñ ÷àò - MYSQL PHP JQUERY CSS3 XHTML

ÄÅÌÎ / ÑÊÀ×ÀÒÜ

Ëèñò çàäà÷ íà ajax, jquery, php è mysql #

Ëèñò çàäà÷ íà ajax, jquery, php è mysql

ÄÅÌÎ / Ñêà÷àòü

Ñêðèïòû Ïðàâêè "íà ìåñòå" #

Ñêðèïòû Ïðàâêè "íà ìåñòå"

1. In-place editing - Ñòðàíèöà ñêðèïòà / Äåìîíñòðàöèÿ ñêðèïòà / Ñêà÷àòü ñêðèïò ñ github

2. Jquery in place editor - Ñòðàíèöà ñêðèïòà / Ñêà÷àòü ñêðèïò ñ code google / Äåìîíñòðàöèÿ ñêðèïòà

3. Jeditable - Edit In Place - Ñòðàíèöà ñêðèïòà / Äåìîíñòðàöèÿ ñêðèïòà / Ñêà÷àòü ñêðèïò

WP áåç MySQL #

Ïëàãèí PDO SQLite îòëè÷íî ðåøàåò âîïðîñ ïåðåõîäîì íà ôàéëîâóþ áàçó ñ íàòèâíîé ïîääåðæêîé â PHP
Îïÿòü æå, áýêàï èñ÷åðïûâàåòñÿ êîïèðîâàíèåì ôàéëà.

Ïåðåä çàïóñêîì óñòàíîâêè WP ðàçâîðà÷èâàåì ñîäåðæèìîå ïàïêè èç àðõèâà â wp-content è ïèøåì â wp-config.php ñòðî÷êó define('DB_TYPE', 'sqlite');

Åñëè âûëèòàåò îøèáêà:
Warning: implode() : Invalid arguments passed in /wp-includes/post.php on line 1762

Òî, Íóæíî äîáàâèòü â ôóíêöèþ escape() â /wp-content/pdo/db.php ïîääåðæêó ìàññèâîâ:
function escape($string) {
if ( is_array($string) ) {
foreach ( (array) $string as $k => $v ) {
if ( is_array($v) )
$string[$k] = $this->escape( $v );
else
$string[$k] = addslashes( $v );
}
} else {
$string = addslashes( $string );
}
return $string;
}

Îãðàíè÷åíèå íà èìïîðò ÁÄ MySQL #

Ïðè ïåðåíîñå îäíîãî ñàéòà ñòîëêíóëñÿ ñ ïðîáëåìîé òîãî ÷òî áàçà äàííûõ î÷åíü æèðíàÿ è íå ïåðåíîñèòñÿ ñòàíäàðòíûìè ñðåäñòâàìè ÷åðåç phpmyadmin. Ïðîáëåìû òàêîãî ðîäà áûâàëè è ðàíüøå, íî ÿ íå ïîìíþ, êàê èõ ðåøàë. Ñåé÷àñ íàøåë ïðîñòîé ñïîñîá ýòî ñêðèïò Sypex Dumper — áåêàï è âîññòàíîâëåíèå ÁÄ MySQL. Ôèøêà â òîì, ÷òî îí íå çàãðóæàåò áåêàï-ôàéë öåëèêîì â ïàìÿòü, áëàãîäàðÿ ÷åìó, åìó áåçðàçëè÷åí ðàçìåð áàçû äàííûõ.

Ñêðèïò ðàñïðîñòðàíÿåòñÿ ïîä ëèöåíçèåé GNU GPL, çà ÷òî èì ðåñïåêò.
Íó è ñàì ñàéò ñ ïîäðîáíîñòÿìè http://sypex.net/