|
|
#1 |
|
Member
Join Date: Jan 2009
Posts: 42
Rep Power: 2 ![]() |
Is there any way I can prevent categories/sub-categories from being shown if there is no listing in them?
I have a site where there are 1200 categories but I only have listings in about 300 of them. It looks really bad to see so many categories with (0) after the title! Thanks Mike
__________________
V4.1.2 Developer Beer.....so much more than a breakfast drink! |
|
|
|
|
|
#2 |
|
Moderator
Join Date: Mar 2008
Posts: 769
Rep Power: 21 ![]() |
First of all why not turn the (0) off so it does not show. Then in showlistings when someone clicks through and the category is empty show the message - Do you want to be the first to place your advert here or show them a set of horzontal random listings or present them another search. Like here
Search Results It is the same principle to adapt showlistings for empty searches and empty categories. It is also SEO smart to avoid duplicate content on different URLs. Secondly but I would not bother, you may be able to test if the category is empty and if it is then don't show it. Use debug to find the variable (if it is available to the browse and home pages for example) and test within this part of code before echoing. {section name=tr loop=$data step=$cols} <tr> {section name=td start=$smarty.section.tr.index loop=$smarty.section.tr.index+$cols} <td> {if $data[td]<>""} <img src="{$data[td].image}" alt="{$data[td].name}" /> {$data[td].start_link|replace:'>':" title=\"`$data[td].name`\" rel='nofollow'>"}<strong>{$data[td].name}</strong></a> {if $data[td].total <> ''} ({$data[td].total}) {/if} {/if} </td> {/section} </tr> {/section} |
|
|
|
|
|
#3 |
|
68 Classifieds Staff
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,750
Rep Power: 110 ![]() |
Maybe something like {if $data[td].total > 0} //show the category {/if}
__________________
Eric Barnes 68 Classifieds Developer Please do not send me a private message asking for support. Instead use these open forums or our ticket system. Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules |
|
|
|
|
|
#4 |
|
Member
Join Date: Jun 2008
Posts: 63
Rep Power: 5 ![]() |
David I think your code is SEO brilliant and is a model to put an <IF> statement to anything -- and Eric, your simplicity is mystically eloquent. Uhhhh, any of you boys care to share *where* your code goes, for us newbies?
![]() Thanks really, Barry
__________________
Using Version 4.0.9 Developer Edition & loving it |
|
|
|
|
|
#5 |
|
68 Classifieds Staff
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,750
Rep Power: 110 ![]() |
Sorry for not including that. Try this. Open home.tpl and you should see something like this:
Code:
{if $data[td]<>""}
Code:
{if $data[td]<>"" && $data[td].total > 0}
__________________
Eric Barnes 68 Classifieds Developer Please do not send me a private message asking for support. Instead use these open forums or our ticket system. Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to show listings in sub-categories? | ksuralta | v4 Questions & Support | 19 | 03-12-2009 02:22 AM |
| How to show list of categories | safatweb | v4 Modules / Modifications | 9 | 10-31-2008 12:53 PM |
| Show Listings help | dollpage | v4 Questions & Support | 3 | 10-09-2008 09:09 PM |
| Show 2nd level categories on homepage? | Success | v4 Questions & Support | 8 | 06-11-2008 09:16 PM |
| Extra Fileds dont show up | MADKing | v3.1 Questions & Support | 10 | 08-12-2007 03:57 PM |