Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27
  1. #21
    Join Date
    Jul 2010
    Location
    Kent UK
    Posts
    50
    Plugin Contributions
    0

    Default Re: Hiding Categories

    Ditched the above this code does it


    $result = mysql_query( 'SELECT categories_id FROM products_to_categories
    WHERE products_id IN (SELECT products_id FROM products WHERE products_status = 1)
    UNION
    SELECT categories.parent_id FROM categories
    WHERE categories.categories_id In (SELECT categories_id FROM products_to_categories)
    UNION
    SELECT parent_id FROM categories
    WHERE categories_id IN( SELECT categories.parent_id FROM categories WHERE categories.categories_id In (SELECT categories_id FROM products_to_categories))
    UNION
    SELECT parent_id FROM categories
    WHERE categories_id IN (SELECT parent_id FROM categories
    WHERE categories_id IN( SELECT categories.parent_id FROM categories WHERE categories.categories_id In (SELECT categories_id FROM products_to_categories)))
    UNION
    SELECT parent_id FROM categories
    WHERE categories_id IN (
    SELECT parent_id FROM categories
    WHERE categories_id IN (SELECT parent_id FROM categories
    WHERE categories_id IN( SELECT categories.parent_id FROM categories WHERE categories.categories_id In (SELECT categories_id FROM products_to_categories))))
    ORDER BY categories_id' );


    $query="update " . TABLE_CATEGORIES . " set categories_status ='0'";
    mysql_query($query) or die(mysql_error());
    while($row = mysql_fetch_array($result))
    {
    echo $row['categories_id'];
    $query="update " . TABLE_CATEGORIES . " set categories_status ='1' where categories_id = '".$row['categories_id']."'";
    mysql_query($query) or die(mysql_error());
    echo '<br>';
    }
    Last edited by WebMC; 23 Nov 2010 at 11:24 PM.

  2. #22
    Join Date
    Oct 2005
    Posts
    286
    Plugin Contributions
    0

    Default Re: Hiding Categories

    Where does this code go? Does it replace the code or get added into functions_categories.php? Line number?

    thanks!

  3. #23
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,761
    Plugin Contributions
    9

    Default Re: Hiding Categories

    marknew,

    Read post #20
    Zen-Venom Get Bitten

  4. #24
    Join Date
    Jul 2010
    Location
    Kent UK
    Posts
    50
    Plugin Contributions
    0

    Default Re: Hiding Categories

    Hi the code works (nothing to do with post 20) - I just created a new php file in the admin for this and usually run it after easy populate. Just included the globals at top of php file (application top)
    - you may want to remove the echo statement if you use it else where...
    Last edited by WebMC; 24 Jan 2011 at 06:51 PM.

  5. #25
    Join Date
    Oct 2005
    Posts
    286
    Plugin Contributions
    0

    Default Re: Hiding Categories

    Thanks WebMC,

    I'm not running easy populate, I'm just trying to hide the empty categories, sorry if I'm on the wrong track here.
    I'm no programmer that's for sure.

    So does the code from your post #21 only apply to easy populate or can i use it to hide empty categories automatically? If so could you spell it out for me? what file, what line etc. As i say I'm no programmer, just a designer hacking around!


    Cheers.

  6. #26
    Join Date
    Jul 2010
    Location
    Kent UK
    Posts
    50
    Plugin Contributions
    0

    Default Re: Hiding Categories

    <?PHP

    require('includes/application_top.php');
    global $db;
    ini_set ("display_errors", "1");
    error_reporting(E_ALL);
    ini_set("memory_limit","80M");


    $result = mysql_query( 'SELECT categories_id FROM products_to_categories
    WHERE products_id IN (SELECT products_id FROM products WHERE products_status = 1)
    UNION
    SELECT categories.parent_id FROM categories
    WHERE categories.categories_id In (SELECT categories_id FROM products_to_categories)
    UNION
    SELECT parent_id FROM categories
    WHERE categories_id IN( SELECT categories.parent_id FROM categories WHERE categories.categories_id In (SELECT categories_id FROM products_to_categories))
    UNION
    SELECT parent_id FROM categories
    WHERE categories_id IN (SELECT parent_id FROM categories
    WHERE categories_id IN( SELECT categories.parent_id FROM categories WHERE categories.categories_id In (SELECT categories_id FROM products_to_categories)))
    UNION
    SELECT parent_id FROM categories
    WHERE categories_id IN (
    SELECT parent_id FROM categories
    WHERE categories_id IN (SELECT parent_id FROM categories
    WHERE categories_id IN( SELECT categories.parent_id FROM categories WHERE categories.categories_id In (SELECT categories_id FROM products_to_categories))))
    ORDER BY categories_id' );


    $query="update " . TABLE_CATEGORIES . " set categories_status ='0'";
    mysql_query($query) or die(mysql_error());
    while($row = mysql_fetch_array($result))
    {
    echo $row['categories_id'];
    $query="update " . TABLE_CATEGORIES . " set categories_status ='1' where categories_id = '".$row['categories_id']."'";
    mysql_query($query) or die(mysql_error());
    echo '<br>';
    }

    ?>

    just put that in a php file and run it when you need to - I have mine in admin folder. You could probably build a function with it - I personally wouldnt put it into a template file because it might be resource intensive. This is all I have done and wasnt planning on taking it any further. To run it just put hyperlink to file obviously.

    If you have shell access you could put it in a cron job if need be
    Last edited by WebMC; 25 Jan 2011 at 12:03 AM.

  7. #27
    Join Date
    Oct 2005
    Posts
    286
    Plugin Contributions
    0

    Default Re: Hiding Categories

    OK thanks, I'll give it a try.

 

 
Page 3 of 3 FirstFirst 123

Similar Threads

  1. hiding categories
    By ian healy in forum General Questions
    Replies: 2
    Last Post: 28 Apr 2008, 04:44 AM
  2. Hiding the top categories
    By maclancer in forum General Questions
    Replies: 0
    Last Post: 23 Jul 2007, 11:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR