Support Forums

Old 05-11-2007, 01:05 PM   #1
Junior Member
 
Join Date: May 2007
Location: Charlotte, NC
Posts: 11
Rep Power: 9
brw9532 is on a distinguished road
Unhappy Limit the number of "New Listing" displays (re-visited)

I'm having a problem that I have seen discussed here before, but the solution is not working for me. I would like to limit the number of displays when people click on �New Listijngs�. It currently shows ALL Listings. Can someone help me limit this?



V3.1.7 Designer
Default template


Below is the code I am using. The [$number=4] should limit my displays to 4. However, all �new� listings are being displayed. (Note: I have even changed the 4 to �4� but that didn�t solve my problem. Any help would be much appreciated!


<?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.3 $
* @Updated: $Date: 2006/05/26 13:14:08 $
*/
function smarty_function_new_listings($params, &$smarty)
{
global $db;

$table_attr = 'border="1"';
$tr_attr = '';
$td_attr = '';
$number=4;
$trailpad = ' ';
$img_break = '<br />';
$date_format = '%B %e, %Y %I:%M %p';

foreach ($params as $_key=>$_value)
{
switch ($_key)
{
case 'number':
$$_key = (int)$_value;
break;

case 'table_attr':
case 'img_break':
case 'date_format':
$$_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."products 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);
$i=0;
while($row=$result->fetch())
brw9532 is offline   Reply With Quote
Old 05-11-2007, 01:24 PM   #2
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,776
Rep Power: 110
Eric Barnes is a jewel in the rough
Default

When you are calling this function can you make sure you do not have a number associated with it or it is also number=4?
__________________
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
Eric Barnes is offline   Reply With Quote
Old 05-11-2007, 01:40 PM   #3
Moderator
 
 
Join Date: Mar 2006
Posts: 4,114
Rep Power: 100
Lhotch is just really niceLhotch is just really nice
Default

You may also want to try and delete the contents of /templates_c
__________________
Larry.
(Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free)

Set your site apart from the competition with one of my modules......
Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module

68 Classifieds Important Links
Customer Area | Issue Tracker | Knowledge Base | User Manuals
Lhotch is offline   Reply With Quote
Old 05-11-2007, 02:35 PM   #4
Senior Member
 
gregbatch's Avatar
 
Join Date: Jun 2006
Posts: 172
Rep Power: 15
gregbatch is on a distinguished road
Default

NOW:
Code:
ORDER BY p.dateadded DESC LIMIT ".$number;
TRY:
Code:
ORDER BY p.dateadded DESC LIMIT ".$number."";
Technically, it should work as is, but I have had some servers refuse to accept a concatenated variable at the tail of a query. Either it gave an error, or ignored that variable completely. Closed it up with quotes and it worked fine. Don't know the reason.
__________________
Greg
3.1.4 Designer

Last edited by gregbatch; 05-11-2007 at 04:53 PM. Reason: additional notes
gregbatch is offline   Reply With Quote
Old 05-11-2007, 05:22 PM   #5
Junior Member
 
Join Date: May 2007
Location: Charlotte, NC
Posts: 11
Rep Power: 9
brw9532 is on a distinguished road
Default Still not working

Thanks for all of your help, but none of these changes worked for me. In fact, I'm really confused. Being an old "tester of programming code" I deleted the "function.new_listings" file just to see what would happen. We'll the program still displayed ALL of the New Listings EVEN without the "function.new_listings" file being there. Why wouldn't I get an error when I attempt to produce the New Listings if the file was gone? Could the program be pulling information from a different file besides the "function.new_listings"? That would explain why none of my changes seem to be working. I'm using the Developer version of the program so I can't access the "toplistings.php" page to see what is going on. Guess I'll be up late tonight trying to figure this out. Any ideas?
brw9532 is offline   Reply With Quote
Old 05-11-2007, 05:35 PM   #6
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,776
Rep Power: 110
Eric Barnes is a jewel in the rough
Default

From that last response I think you are looking in the wrong place. The smarty function is only used by placing code in the template file. For example:

Code:
{new_listings number=4}
The toplistings.php file pulls out all the data in that file. If you open you should be able to see a global variable: MAX_ROWS_SEARCH

Here is the actual limit clause:
PHP Code:
$offset = ($pageNum 1) * MAX_ROWS_SEARCH;
    
$searchSQL sprintf("%s LIMIT %d, %d"$sSQL$offsetMAX_ROWS_SEARCH); 
__________________
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
Eric Barnes is offline   Reply With Quote
Old 05-11-2007, 07:06 PM   #7
Junior Member
 
Join Date: May 2007
Location: Charlotte, NC
Posts: 11
Rep Power: 9
brw9532 is on a distinguished road
Default

Sounds like we're heading in the right direction! But, when I open "toplistings.php" in the root directory" I see what looks like scrambled data:


(example of what I see, 4+oV5CfIvrml3ToJ8f5oV/0Dzu//XX
ZhDyAlqOQiGIAA8SJmvvAqGH68eZh6180XcWEeiKOHncQH
6ZZlF+x9PlwF7CPINyOaXaaqcaZ/IniQ/qZqQh13bywZGSU
P4NTojtuEHLVXdAe9UN+xed4zDPbEnudB4xVzv6fDYvvjQno
EuSlcwwBss4zZSo0p5lGIMG/+U4ZU/UFTEF/HLC55QGyVbu
wJRuV+e6+CBIikTxj69j+8y/FlQH+qFtC8/X2VJf0S7yXgg
EfsIaraXVmhJCPZyyvmVB6O1Fz9FRzhFweVa/huc
sK2Ry4D+IlgW08o7)



I naturally assumed this is because I have the Designer version of the program and many of the PHP files have been protected. Or, am I looking in the wrong place or have a done something else wrong?
brw9532 is offline   Reply With Quote
Old 05-12-2007, 12:36 PM   #8
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,776
Rep Power: 110
Eric Barnes is a jewel in the rough
Default

Yes with the Designer edition that file is encoded. The only work arounds that I can think of are to either purchase the Developer edition or some how use the external.php file with an rss parser to display x amount of new listings.
__________________
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
Eric Barnes is offline   Reply With Quote
Old 05-12-2007, 09:10 PM   #9
Junior Member
 
Join Date: May 2007
Location: Charlotte, NC
Posts: 11
Rep Power: 9
brw9532 is on a distinguished road
Default

Thanks for your help. I was thinking about getting the Developers version at some point anyway.
brw9532 is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Limit number of ads by usergroups? z0rg v3.1 Questions & Support 2 11-28-2006 09:39 AM


All times are GMT -4. The time now is 10:53 PM.


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