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

Show subcategories on homepage

Discussion in 'Customizations' started by redking, May 31, 2009.

  1. redking Customer

    I need to have subcategories shown on home page (like those in the picture)

    [IMG]
  2. seymourjames All Hands On Deck

    You will need to do a few things. First of all you will need to edit your home.tpl page to show the sub categories. Remove the comments <!- and --> from this line below
    <!--{$data[td].subcats}-->


    As you do not want to show decriptions under the categories you can comment the description out so it looks like this

    <!--{$data[td].description}-->

    Then you will need to change your category image for a dot. Finally and beyond the scope here, you will need to adjust your css style sheet to get exactly what you are asking for.
  3. michael Just get on with it!

    In v4.1.3

    Go to includes>classes>kernel>Categories.php and insert a <br /> at the end of lines 98 and 103 (in place of &nbsp; ).

    While you're there you might also like to increase your subcategory limit at line 92. The default is just 3.

    Good luck.
    tango likes this.
  4. Hey Me Customer

    Hi, thanks I've just done that, but wondering how I could add <ul><li> instead of <br /> ?

    The $limit=3 is in line 87 btw in my categories.php (4.1.4)
  5. bowers01 Genius At Work

  6. Hey Me Customer

    For the dots just remove "LANG_DOT_DOT_DOT." from Categories.php

    Donno about those blank areas in tables.
  7. Mike-N-Tosh Owner

    The issue that you are seeing is that within the browse.tpl file the array data is being put into a table cell <td> with the parent category, then each subcategory. The nature of a data cell within a table is that it will always auto adjust the height to contain the data within it. In your picture you have a table with two columns and therefore when one <td> has several subcategories it will make the height larger and will leave white space in the adjacent <td> that does not have as many of the subcategories.

    The only way that I know of to get around that is to rewrite the browse.tpl file to use CSS boxes to contain the data instead of a table. This will get complicated and you would have to be an advanced coder for smarty and CSS to accomplish this.
  8. michael Just get on with it!

    Nick, the categories are stored in table cells so those gaps are unavoidable unless you rewrite that part of your page to use CSS instead.
  9. michael Just get on with it!

    Seriously Mike, how the hell did you get your response in 15 minutes before mine! You weren't there when I started typing like 5 minutes ago!!
    :eek::confused:
  10. Mike-N-Tosh Owner

    I use "The Force"! You must not have the force or you would have felt my presence. :D
    krystle likes this.
  11. adexinc Customer

    Smarty and CSS to rewrite code browse.tpl question

    Hi,

    I am looking to rewrite the code so that the subcategories listed on the homepage to not appear in tables... before I begin I would like to see if anyone has already done this and is willing to share some code.

    I have searched for this but it appears like there is no specific data provided as to what to do and where :D

    Anyways, as always any 'help' is appreciated.

    Thank you
    Joanna

  12. freeze2 Super Moderator

    Hi there...I think this is what you're after...

    http://www.68classifieds.com/forums/v4-1-questions-support/8291-using-divs-instead-table-columns-home-page.html
  13. guillopuig Customer


    I have a little problem here... The categories.php file is encoded in my designer version therefore I cannot make the change mentioned.

    It currently looks like this:


    [IMG]




    I would like the subcategories to appear with a bullet in a straight column under the parent category. Like:



    [IMG]



    Any suggestions?
  14. freeze2 Super Moderator

    This is the code I used in the Categories.php file...I believe you will need the Developer edition to make the change.

    HTML:
    function getSubCategoriesList($parent, $limit=99)
    	{
    		global $db;
    		$add_cats='';
    		$sSQL2 = "SELECT id,name,slug,image,cLink FROM ".PREFIX."categories WHERE parent_id = ".$parent." AND display<>'N' ORDER BY cORDER DESC, name ASC LIMIT ".$limit;
    		$result2=$db->query($sSQL2);
    		while($rs=$result2->fetch())
    		{
    			$rs['name'] = htmlspecialchars($rs['name']);
    			if($rs['cLink']<>"")
    			{
    				$add_cats.='<li><a href="'.$rs['cLink'].'" title="'.$rs['name'].'">'.$rs['name'].'</a></li>';
    			}
    			else
    			{
    				$slug = ( empty($rs['slug']) ) ? $rs['id']: $rs['slug'];
    				$add_cats.='<li><a href="category.php?cat='.$slug.'" title="'.$rs['name'].'">'.$rs['name'].'</a></li>';
    			}
    			
    		}
    		if($add_cats=="")
    		{
    			$sub=htmlspecialchars($rs['description']);
    		}
    		else
    		{
    			$sub='<div class="small"><ul class="list1">'.$add_cats.'</ul></div>';
    		}
    		return $sub;
    	}
    Just style the css as you like...
  15. guillopuig Customer

    How can I add the folder.gif image to the subcategories?

    How can I eliminate the space between categories?

    This is my current set up:
    [IMG]
  16. seymourjames All Hands On Deck

    What you should be doing is using Firefox with the free web developer extension. You can then see what css is being used on the subcategory links. Then you can embed your image into that picee of css doing the work. It is also the same when looking at the spacing; You could however quickly make it 4 columns across though couldn't you if this is in a table.
  17. guillopuig Customer

    hey James... i did get the firefox extension you mentioned. however, i have no idea which css section it is. All i see is style details. would you be kind enough to expand a little. check the page out at pranuncia.com. I had to reduce the number of subcategories down to 5 just for it to look w/o so much space under each main category.

    the two details id like to have done are.

    1. folder.gif image in front of the subcategories
    2. no space between categories when displaying all subcategories.

    i am launching the site this coming week and was hoping to get this done before then. Not too sure i'll be able to.

    anyways... thank you in advance for any help.


  18. guillopuig Customer

  19. freeze2 Super Moderator

    You're welcome...all the best on the new site!
  20. krystle New Member

    Hi all I am wanting to do exactly what what posted as the thread question but in the 'browse' page instead.
    This also spawns a new question of if it's possible and if so how to create 2 separate category listings areas;

    a. the browse categories option on the home page serviceforservice.com I want to keep 'as is' and as can be seen currently seen on this page;
    --> www.serviceforservice.com
    but....

    b. I also want a second browse categories section in the browse page --> http://www.serviceforservice.com/category.php to display what the first image on this thread displays (child categories listed under their parent categories. So it's not just a duplicate of the home page one which only displays parent categories.

    As these are two separate functions I can't just replace the code in the page I want it on.

    Any help and direction would be great!

    Cheers heaps!

Share This Page