Support Forums

{New_Listings} Smarty Plugin - adding city and state

This is a discussion on {New_Listings} Smarty Plugin - adding city and state within the Customizations forums, part of the Developer Forums category; Has anyone been able to add the city and state to the new_listing plugin, I went into the smarty plugin ...


Go Back   68 Classifieds Forums > Developer Forums > Customizations

Reply
 
Thread Tools Display Modes
Old 11-15-2009, 02:17 PM   #1
Customer
 
Join Date: Nov 2007
Location: Metro Detroit
Posts: 79
Rep Power: 19
LittleRascal is on a distinguished road
Default {New_Listings} Smarty Plugin - adding city and state

Has anyone been able to add the city and state to the new_listing plugin, I went into the smarty plugin hoping that I could just add to highlited code below, but no such luck! If anyone could help me out, that would be much appreciated..not sure if their is more stuff I need to add to the plugin

The file is located in your /includes/classes/smarty/plugins/function.new_listings.php

Thanks,


$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())
{
$tmp = array(
'id' => $row['id'],
'title'=> $row['title'],
'city'=> $row['city'],
'state'=> $row['state'],

'dateadded'=>$row['dateadded'],
'price'=> FormatCurrency($row['price']),
);
$loop[$i++] = $tmp;
__________________
David Anthony Schnoblen
Mom2MomTrader
My Email
v 4.1.9 Developer
Templates: Default 3 Col
LittleRascal is offline   Reply With Quote
Old 11-15-2009, 03:19 PM   #2
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 3,517
Rep Power: 89
seymourjames is a jewel in the rough
Default

And how are you defining output in that function?
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68C
seymourjames is offline   Reply With Quote
Old 11-15-2009, 04:15 PM   #3
Customer
 
Join Date: Nov 2007
Location: Metro Detroit
Posts: 79
Rep Power: 19
LittleRascal is on a distinguished road
Default New_listings Smarty plugin

I don't really know to much about programming, not sure by what you mean in your question. I thought the new listing plugin in would be able to use the city and state.


ok i think after looking at the code...i see what you mean by output file...
__________________
David Anthony Schnoblen
Mom2MomTrader
My Email
v 4.1.9 Developer
Templates: Default 3 Col

Last edited by LittleRascal; 11-15-2009 at 04:22 PM.
LittleRascal is offline   Reply With Quote
Old 11-15-2009, 04:19 PM   #4
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 3,517
Rep Power: 89
seymourjames is a jewel in the rough
Default

so you have added stuff which looks correct but where you have the output lines in that function have you made any changes? Otherwise how can it display the information.
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68C
seymourjames is offline   Reply With Quote
Old 11-15-2009, 04:54 PM   #5
Customer
 
Join Date: Nov 2007
Location: Metro Detroit
Posts: 79
Rep Power: 19
LittleRascal is on a distinguished road
Default newest listing city and state....

Quote:
Originally Posted by LittleRascal
I don't really know to much about programming, not sure by what you mean in your question. I thought the new listing plugin in would be able to use the city and state.


ok i think after looking at the code...i see what you mean by output file...
I got it to work now....

<?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 68 Classifieds - PHP Classifieds Script
* @$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())
{
$tmp = array(
'id' => $row['id'],
'title'=> $row['title'],
'city'=> $row['city'],
'state'=> $row['state'],
'price'=> FormatCurrency($row['price']),
'dateadded'=>$row['dateadded'],

);
$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.=$loop[$x][city];
$output.="</td>\n";
$output .= "<td" . smarty_function_html_table_cycle_newlistings('td', $td_attr, $c) . ">\n";
$output.=$loop[$x][state];
$output.="</td>\n";
$output .= "<td" . smarty_function_html_table_cycle_newlistings('td', $td_attr, $c) . ">\n";
//$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 : '';
}
?>
__________________
David Anthony Schnoblen
Mom2MomTrader
My Email
v 4.1.9 Developer
Templates: Default 3 Col

Last edited by LittleRascal; 11-15-2009 at 05:10 PM.
LittleRascal is offline   Reply With Quote
Reply

Tags
function.new_listings.php , home.php , new_listing , smarty plugins

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
New listing in main content to contain city and state LittleRascal Technical Support 1 06-13-2009 02:29 AM
Issue with new_listings plugin jason1971 Technical Support 3 05-07-2009 08:34 AM
City, state and country hel68c Technical Support 2 06-08-2008 05:07 PM


All times are GMT -4. The time now is 12:51 AM.


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