1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Displaying all subcats ads under main cat

Discussion in 'Templates, HTML, CSS, and Design Help' started by EnergyFreak, Apr 7, 2011.

  1. EnergyFreak Customer

    I would like to state my current version just so this clarify's the possibilities. V4.2.2. Developer.

    Basically what I am looking for is to display all the subcats listings on my main cat, e.g. Vehicles -> Cars, Trucks, etc. Since I restricted people from adding their ads under the main cat and skip the sub cats, this gives me 0 ads under my vehicles category. Simply to add simplicity for users that are not looking for something in particular, I wanted to make this available to them.

    In simplified terms, I do not want people posting under the main cat but I want to display all the ads of its subcats under the main cat. (Not sure if that help lol)

    Where should I start? Are there resources out there that can help me accomplish this? Is there simply one line that I must change or perhaps change something in a plugin?

    Thanks.
  2. seymourjames All Hands On Deck

    Search the forum. There are several threads about how to do this with developer version by modifying category.php. Some may now be out of date but I do remember one thread which gave the solution to do just what you are seeking to do.
  3. EnergyFreak Customer

    I found some of the code from Eric on the forum, He posted this solution a while back:

    To show all listings open category.php and find:
    $showlistings='N';

    Change to:
    $showlistings='Y';

    Find:
    $options['section']=$sec;
    Change to:
    if(isset($sec)) {
    $options['section']=$sec;
    }
  4. EnergyFreak Customer

    This code works, although it does not for me because I do not let anyone post in the main cats, they have to post in the sub-cats, therefore this code makes the main cats display all the ads from every cat onto each main cat.

    Can this code be changed to my needs?
  5. Mike-N-Tosh Owner

    I would try this:
    PHP:
    if(isset($sec) && $sec XX) {
    $options['section']=$sec;
    }
    $sec = XX <-- replace XX with the category id for your category

    Dont forget to add inline comments on ALL MODIFICATIONS that you make to make it easier to identify before you upgrade in the future.
  6. John Snyder Staff

    Here is a bit of untested/unsupported code to get you started in the right direction.

    open category.php

    add in on line 80 (since you don't want to allow ads it won't show ads)

    PHP:
    $showlistings "Y";
    below on line 92:

    find:

    PHP:
    $options['section'] = $sec;
    change to:

    PHP:
    //$options['section'] = $sec;
     
    $arr_childs = array();
     
    $Categories->get_ids(array($sec));
     
    $options['arr_childs'] = $arr_childs;
  7. EnergyFreak Customer

    @ John Snyder. The code works and displays all the ads of the child categories under the main category, except that, now the child categories do the same and display all the ads of that category as well. Instead of displaying only the child category ads. Oh and thanks for the input! :D
  8. Dawn Brown New Member

    I think you can solve the problem by modifying category.php page.

Share This Page