Support Forums

total_listings plugin amendment (if poss)

This is a discussion on total_listings plugin amendment (if poss) within the Templates, HTML, CSS, and Design Help forums, part of the General category; Hi all, Would it be possible to create a copy of the plugin {total_listing} to only show the number of ...


Go Back   68 Classifieds Forums > General > Templates, HTML, CSS, and Design Help

Reply
 
Thread Tools Display Modes
Old 03-03-2010, 11:37 PM   #1
Customer
 
jason1971's Avatar
 
Join Date: Jan 2009
Location: England
Posts: 147
Rep Power: 13
jason1971 is on a distinguished road
Default total_listings plugin amendment (if poss)

Hi all,

Would it be possible to create a copy of the plugin {total_listing} to only show the number of listings for a certain catergory either via category name or category id ?, as the code is short i have copied it here, but as usual im not sure what to put where so any help gratefully received Jason

* @param return int Total number.
*/
function smarty_function_total_listings($params, &$smarty)
{
global $db;

$sSQL="SELECT COUNT(*) AS total FROM ".PREFIX."listings WHERE expiration > NOW() AND display = 'Y'";
$result=$db->query($sSQL);
$rs=$result->fetch();
$total_listings=$rs['total'];

return $total_listings;
}
__________________
v4.1.8 Hosted - using Templatecodes neo2- green template
jason1971 is offline   Reply With Quote
Old 03-04-2010, 09:30 AM   #2
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

You can try something like this:
PHP Code:
function smarty_function_total_listings($params, &$smarty)
{
    global 
$db;
    
    
$category '';
    
    foreach (
$params as $_key=>$_value
    {
        switch (
$_key
        {
            case 
'category':
                $
$_key = (int)$_value;
                break;
        }
    }
    
    
$sSQL="SELECT COUNT(*) AS total FROM ".PREFIX."listings WHERE expiration > NOW() AND display = 'Y'";
    if (
$category != '')
    {
        
$sSQL .= ' AND section = '$category;
    }
    
$result=$db->query($sSQL);
    
$rs=$result->fetch();
    
$total_listings=$rs['total'];

    return 
$total_listings;

Then in your template:
Code:
{total_listings category=1}
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 03-04-2010, 09:55 AM   #3
Customer
 
jason1971's Avatar
 
Join Date: Jan 2009
Location: England
Posts: 147
Rep Power: 13
jason1971 is on a distinguished road
Default

HI Eric,

I tried as you suggested but it isnt working, it just blanks out the whole page, any other thoughts ?

By the way thanks for the help

Jason
__________________
v4.1.8 Hosted - using Templatecodes neo2- green template
jason1971 is offline   Reply With Quote
Old 03-04-2010, 10:08 AM   #4
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Make sure in the plugin file you but that function inside <?php ?> tags. That wasn't included in the sample.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 03-04-2010, 12:32 PM   #5
Customer
 
jason1971's Avatar
 
Join Date: Jan 2009
Location: England
Posts: 147
Rep Power: 13
jason1971 is on a distinguished road
Default

Hi Eric,

Many many thanks got it sorted thanks to you.

Regards

Jason
__________________
v4.1.8 Hosted - using Templatecodes neo2- green template
jason1971 is offline   Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
New_listings plugin jason1971 Templates, HTML, CSS, and Design Help 2 02-25-2010 12:44 PM
last_viewed plugin jason1971 Templates, HTML, CSS, and Design Help 0 02-21-2010 04:06 AM
Is this {Total_Listings} current with 4.1x? Bronxgodzilla Technical Support 1 09-20-2009 06:13 AM
Is this {Total_Listings} Var current? Bronxgodzilla Technical Support 1 09-19-2009 02:54 PM
Plugin Help dollpage Technical Support 12 10-13-2008 04:37 PM


All times are GMT -4. The time now is 03:13 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0