Support Forums

New listings on homepage please

This is a discussion on New listings on homepage please within the Technical Support forums, part of the Technical Support Forums category; Can anyone tell me a way to show the latest (say 10) ads on the homepage. I'm after a list ...


Go Back   68 Classifieds Forums > Technical Support Forums > Technical Support

This topic is resolved.

If you have a similar issue that this thread does not address, open a new related support topic.

 
Thread Tools Display Modes
Old 07-01-2007, 04:29 PM   #1
Senior Member
 
Join Date: Sep 2006
Posts: 236
Rep Power: 18
Tim_A is on a distinguished road
Default New listings on homepage please

Can anyone tell me a way to show the latest (say 10) ads on the homepage.

I'm after a list (no images) with prices, that can be put into a javascript ticker etc.

Thanks for any replies


UPDATE:

just tried using this suggested script:
{new_listings number=8 table_attr='width="100%" style="border: 1px solid #000;"' td_attr='valign="middle" align="left"' img_break="
"}

and it throws up this error:

Notice: Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 SQL: SELECT p.id, p.owner, p.title, p.featured, p.section, p.description, p.price, p.dateadded, p.expiration, p.pHighlighted, p.pBold, u.state, u.city, u.country FROM class_listings AS p LEFT JOIN class_users AS u ON p.owner = u.id WHERE p.expiration > NOW() AND p.display = 'Y' ORDER BY p.dateadded DESC LIMIT in /home/******/public_html/includes/classes/database/mysql.php on line 142

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/******/public_html/includes/classes/database/mysql.php on line 202

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/******/public_html/includes/classes/database/mysql.php on line 225
__________________
V4.0.9 Developer

Last edited by Tim_A; 07-01-2007 at 05:02 PM.
Tim_A is offline  
Old 07-04-2007, 07:55 AM   #2
Senior Member
 
Join Date: Sep 2006
Posts: 236
Rep Power: 18
Tim_A is on a distinguished road
Default

cheeky bump

can anyone help?
__________________
V4.0.9 Developer
Tim_A is offline  
Old 07-08-2007, 12:51 AM   #3
Member
 
Join Date: Jun 2007
Posts: 40
Rep Power: 11
Syafi is on a distinguished road
Default

Syafi is offline  
Old 07-19-2007, 05:58 AM   #4
Senior Member
 
Join Date: Sep 2006
Posts: 236
Rep Power: 18
Tim_A is on a distinguished road
Default

REAAALLY Cheeky bump!

I've been playing around with implementing RSS feeds onto the homepge and got them working okay, I just couldn't get the price to show up for the ads.

Can anyone please help me get a list of 10 latest ads onthe homepage? No images, just list and price so I can put them in a list/ticker.

Thanks
__________________
V4.0.9 Developer
Tim_A is offline  
Old 07-19-2007, 09:24 AM   #5
Coder
 
Join Date: Mar 2006
Posts: 4,902
Rep Power: 120
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

I havent even installed v4 yet but when you say homepage do you mean the classifieds main home page or a different home page for your main site?

As for RSS in V3 there was a file called external.php which created an RSS feed for you. Im not sure if the updated version of it was every bundled in with the newer v3 or not but I created one which you can find on the forums here, try a search for external.php
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 07-19-2007, 09:50 AM   #6
Senior Member
 
Join Date: Sep 2006
Posts: 236
Rep Power: 18
Tim_A is on a distinguished road
Default

Hi Larry,

I mean the index page of 68 (either in the layout.tpl or home.tpl).

I've searched through the forums and tried everything with external.php, and have managed to get the names/descriptions working with an rss displayer, but not the prices.

V4 external.php version is:

@version 3.1
* @$Revision: 1.4 $

if that helps??

Is there just a call I can make to display the last x adverts (like featured does)??

Kind Regards
__________________
V4.0.9 Developer
Tim_A is offline  
Old 07-19-2007, 11:08 AM   #7
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,293
Rep Power: 124
Eric Barnes is a jewel in the rough
Default

Try this. Replace the file includes/classes/smarty/plugins/function.new_listings.php with this code below:

PHP Code:
<?php
/**
* smarty_function_new_listings
*
* This function is useful for generating a vertical table of new listings.
*
* All source code & content (c) Copyright 2006, 68 Classifieds
* unless specifically noted otherwise.
*
* @package 68classifieds
* @author  Eric Barnes
* @copyright 68 Classifieds
* @link http://www.68classifieds.com
* @$Revision: 1.2 $
* @Updated: $Date: 2007/01/12 14:35:50 $
*/
function smarty_function_new_listings($params, &$smarty)
{
    global 
$db;
    
    
$table_attr 'border="1"';
    
$tr_attr '';
    
$td_attr '';
    
$number=4;
    
$cols=4;
    
$rows=3;
    
$trailpad ' ';
    
$vdir 'down';
    
$hdir 'right';
    
$inner 'cols';
    
    foreach (
$params as $_key=>$_value
    {
        switch (
$_key
        {
            case 
'number':
                $
$_key = (int)$_value;
                break;

            case 
'table_attr':
                $
$_key = (string)$_value;
                break;

            case 
'tr_attr':
            case 
'td_attr':
                $
$_key $_value;
                break;
        }
    }
    
    
$sSQL="SELECT p.id, p.owner, p.title, p.featured, p.section, p.description, p.price, p.dateadded, p.expiration, p.pHighlighted, p.pBold, u.state, u.city, u.country FROM ".PREFIX."listings AS p LEFT JOIN ".PREFIX."users AS u ON p.owner = u.id WHERE p.expiration > NOW() AND p.display = 'Y' ORDER BY p.dateadded DESC LIMIT ".$number;
    
$result=$db->query($sSQL);
    while(
$row=$result->fetch())
        {
            
$tmp = array(
                
'id' => $row['id'],
                
'title'=> $row['title'],
                
'dateadded'=>$row['dateadded'],
                
'price'=> FormatCurrency($row['price']),
                );
                
$loop[$i++] = $tmp;
        }
    
$loop_count count($loop)-1;

    
$output "<table " $table_attr.">\n";
    for (
$x 0$x<= $loop_count$x++)
    {
        
//opening tr
        
$output .= "<tr" smarty_function_html_table_cycle_newlistings('tr',   $tr_attr$c) . ">\n";
        
//opening td
        
$output .= "<td" smarty_function_html_table_cycle_newlistings('td',   $td_attr$c) . ">\n";
            
//title
            
if(defined('SEO'))
            {
                
$listing_title=$loop[$x][title];
                
$listing_title=str_replace(' ''_'$listing_title);
                
$listing_title=preg_replace('/\W/e'''$listing_title);
                
$output.="<a href='listing/".$loop[$x][id]."/".$listing_title.".html'>".$loop[$x][title]."</a>";    
            }
            else
            {
                
$output.="<a href='viewlisting.php?view="$loop[$x][id] ."'>".$loop[$x][title]."</a>";
            }
            
$output.="</td>\n";
            
$output .= "<td" smarty_function_html_table_cycle_newlistings('td',   $td_attr$c) . ">\n";
            
//price
            
$output.=$loop[$x][price];
            
$output.="</td>\n";
            
$output .= "<td" smarty_function_html_table_cycle_newlistings('td',   $td_attr$c) . ">\n";
            
//date
            //$output.=smarty_modifier_date_format($loop[$x][dateadded], $date_format);
        //closing td
        
$output.="</td>\n";
        
$output .= "</tr>\n";
    }
    
$output .= "</table>\n";

    return 
$output;
}

function 
smarty_function_html_table_cycle_newlistings($name  $var$no)
{
    if(!
is_array($var))
    {
        
$ret $var;
    }
    else
    {
        
$ret $var[$no count($var)];
    }
    return (
$ret) ? ' '.$ret '';
}
?>
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline  
Old 07-19-2007, 04:33 PM   #8
Senior Member
 
Join Date: Sep 2006
Posts: 236
Rep Power: 18
Tim_A is on a distinguished road
Default

You're a star... perfect

I added a little code to remove the price if it's �0.00 (for business listings) and it works a treat!

Does it have the ability to show the date???

Cheers

Tim

p.s. Don't suppose you've got a 'top listings' script knocking about back there have you??
__________________
V4.0.9 Developer
Tim_A is offline  
Old 07-19-2007, 04:43 PM   #9
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,293
Rep Power: 124
Eric Barnes is a jewel in the rough
Default

The date is included but commented out:
PHP Code:
//$output.=smarty_modifier_date_format($loop[$x][dateadded], $date_format); 
I think the reason for this was because you can't call a smarty modifier from a plugin. But you can use something like:
$output.=$loop[$x][dateadded];

and use php to format the date.

Quote:
p.s. Don't suppose you've got a 'top listings' script knocking about back there have you??
Nope I don't have one of these. However you could make a copy of the new listings function and change the query to use:
ORDER BY hitcount DESC
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline  
Old 07-19-2007, 04:48 PM   #10
Senior Member
 
Join Date: Sep 2006
Posts: 236
Rep Power: 18
Tim_A is on a distinguished road
Default

I'm afraid I wouldn't have a clue where to start with the date....


i'll have a go at the top listings though
__________________
V4.0.9 Developer
Tim_A is offline  
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to display category total listings? dankellaway v3.1 Questions & Support 2 03-13-2007 02:25 PM
Featured Listings on homepage martini55 v3.1 Questions & Support 6 09-20-2006 03:07 PM
Top Listings sbuell20 v3.1 Questions & Support 0 09-02-2006 01:11 PM
Showing most recent listings on homepage martini55 v3.1 Questions & Support 7 08-14-2006 04:15 PM
Help? Newest listings on homepage showing ALL Listings zman78 v3.1 Modules & Modifications 5 05-26-2006 08:47 PM


All times are GMT -4. The time now is 04:53 AM.


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