68 Classifieds Forums
Go Back   68 Classifieds Forums > v3.1.x Help & Support > v3.1 Questions & Support > Displaying merchant's company name on browsed listings
v3.1 Questions & Support Help and support for 68 Classifieds v3.1.x

 
Thread Tools Display Modes
(#1)
Old
cooldeals cooldeals is offline
Junior Member
cooldeals is on a distinguished road
 
Posts: 11
Join Date: Oct 2006
Default Displaying merchant's company name on browsed listings - 11-04-2006, 06:03 AM

I would like to show the company's name next to advertisement on the browsed listing pages. Any suggestions will be much appreciated.
Thanks
Anton
Christchurch
Reply With Quote
(#2)
Old
motoenth motoenth is offline
My Red Light is blinking
motoenth is on a distinguished road
 
Posts: 164
Join Date: Mar 2006
Default 11-04-2006, 07:24 AM

Hi Anton-

When you visit the page you want to modify in your browser, I'm assuming it is the toplistings.php page?

If so, you'll need the developer edition to apply the change as it'll require modifying the query to pull the company name from the database then assigning the value so that value can be passed to the template.

Open toplistings.php
Around line 73. You should see:
Code:
$sSQL="SELECT p.id, p.owner, p.title, p.display, p.featured, p.section, p.shortDescription, p.description, p.price, p.dateadded, p.expiration, p.pHighlighted, p.pBold, u.state, u.city, u.country".$select." FROM ".PREFIX."products AS p LEFT JOIN ".PREFIX."users AS u ON p.owner = u.id WHERE p.expiration > NOW() AND p.display = 'Y' ". $wherehook . $where;
Between u.country and the double quote next to it, enter:
Code:
u.extra
(Assuming, of course, that you're not using that extra field for something already)

Then, down around line 124:
Code:
$row['image']=htmlspecialchars($irs['image']); $row['title']=$pre.safeStripSlashes($row['title']).$post;
add a new line:
Code:
$row['image']=htmlspecialchars($irs['image']); $row['extra']=$pre.safeStripSlashes($row['extra']).$post; $row['title']=$pre.safeStripSlashes($row['title']).$post;
Save and close toplistings.php

Open templates/<your template name>/showlistings.tpl.php (or showlistings2.tpl.php - if you're using it) and look around line 52:
Code:
{if $sDisPhoto == "Y"} <th>{$smarty.const.LANG_PHOTO}</th> {/if} <th>Company Name</th> {if $sDisTitle == "Y"} <th>{$smarty.const.LANG_TITLE}</th> {/if}
Around line 80. Change it to:
Code:
{if $sDisPhoto == "Y"} <td{if $entry.class<>""} class="{$entry.class}"{/if}><a href="{$entry.link}">{if $entry.image != ""}<img src="thumbs/small_{$entry.image|escape:"url"}" border="0" />{else}<img src="images/nophotosmall.gif" border='0' />{/if}</a></td> {/if} {if $entry.extra<>""} <td{if $entry.class<>""} class="{$entry.class}"{/if}>{$entry.extra}</td> {else} <td{if $entry.class<>""} class="{$entry.class}"{/if}> </td> {/if} {if $sDisTitle == "Y"} <td{if $entry.class<>""} class="{$entry.class}"{/if}>{$entry.title}</td> {/if}
Change the colspan attribute to 10 in line 110.

Uh... that should be it. I think I've just rebuilt the engine when it was only the tank that was out of gas

Now, you need to ask the customer for their company name and get it inserted in the 'extra' cell of the user's table.


---------
Blair
Eric's favorite business partner since 2002!

Last edited by motoenth : 11-04-2006 at 07:31 AM.
Reply With Quote
(#3)
Old
Chaslie Chaslie is offline
Moderator
Chaslie is on a distinguished road
 
Posts: 494
Join Date: Mar 2006
Location: Great Ocean Road - Australia
Default 11-07-2006, 09:16 PM

Blair,
What you have provided above is excellent.

Using the same type of process/principle above, how are extra fields identified to be added to top listings? ie: If I am looking to call up an extra field result with the fID of 34, how do I do that?

Given this field is also located in another table other than 'u' or 'p', is this too great a task to manually code it in or should it be added as a module?

I'm looking to add x3 extra field results to my toplistings, showlistings and search results. If I can get a start with top listings, think I can work out the others.


Chaslie
V3.1.4 dev
mods.auscity.com
AUSCITY
Reply With Quote
(#4)
Old
Maffo Maffo is online now
Senior Member
Maffo is on a distinguished road
 
Posts: 545
Join Date: Mar 2006
Location: English in Argentina
Send a message via MSN to Maffo
Default 11-07-2006, 10:25 PM

The extra Blair has included is one from the extra fields from the User registration where as the results you want are from extra fields for the products.

You can insert a call inside the while loop underneath, around line 83

PHP Code:
while ($row=$result->fetch());


The call would be something like (sorry this is rough), I only use the 'maf' so as not to conflict with anything else.

Insert before the //now get the images

PHP Code:
//Get custom extra field
$mafSQL = "SELECT sValue FROM ".PREFIX."products_fields WHERE pID=".$row['id']." AND fID=34 LIMIT 1";
        
$mafResult=$db->query($mafSQL);
        
$mafrs=$mafResult->fetch();
                
$row['mafExtra']=$mafrs['sValue'];
I havent tested this but this should send your desired result to the the showlistings.tpl

You may also want to insert this code into searchresults.php and category.php where the code is pretty much the same.

IF ANYONE ELSE WISHES TO USE THIS REMEMBER!!! YOU MUST CHANGE THE 'fID' number to the number that suits your site. 34 is specifically for Chaslies!

Last edited by Maffo : 11-07-2006 at 10:39 PM.
Reply With Quote
(#5)
Old
Chaslie Chaslie is offline
Moderator
Chaslie is on a distinguished road
 
Posts: 494
Join Date: Mar 2006
Location: Great Ocean Road - Australia
Default 11-07-2006, 10:35 PM

Go on ya maffo - adding this now - thanks.


Chaslie
V3.1.4 dev
mods.auscity.com
AUSCITY
Reply With Quote
(#6)
Old
Maffo Maffo is online now
Senior Member
Maffo is on a distinguished road
 
Posts: 545
Join Date: Mar 2006
Location: English in Argentina
Send a message via MSN to Maffo
Default 11-07-2006, 10:37 PM

Cool, get back to me
Reply With Quote
(#7)
Old
Chaslie Chaslie is offline
Moderator
Chaslie is on a distinguished road
 
Posts: 494
Join Date: Mar 2006
Location: Great Ocean Road - Australia
Default 11-07-2006, 11:00 PM

Maffo - works great.

If you wish to add a second extra field, what changes would you make to this (lets say it is fID 23)

Quote:
//Get custom extra field
$mafSQL = "SELECT sValue FROM ".PREFIX."products_fields WHERE pID=".$row['id']." AND fID=34 LIMIT 1";
$mafResult=$db->query($mafSQL);
$mafrs=$mafResult->fetch();
$row['mafExtra']=$mafrs['sValue'];


Chaslie
V3.1.4 dev
mods.auscity.com
AUSCITY
Reply With Quote
(#8)
Old
Maffo Maffo is online now
Senior Member
Maffo is on a distinguished road
 
Posts: 545
Join Date: Mar 2006
Location: English in Argentina
Send a message via MSN to Maffo
Default 11-07-2006, 11:15 PM

Hey you!! You changed your post!!!

If you want a second you will have to repeat the code

so
PHP Code:
//Get custom extra field 2
$mafSQL = "SELECT sValue FROM ".PREFIX."products_fields WHERE pID=".$row['id']." AND fID=?? LIMIT 1";
$mafResult=$db->query($mafSQL);
$mafrs=$mafResult->fetch();
$row['mafExtra2']=$mafrs['sValue'];
Change the fID number and also in the bottom line notice $row['mafExtra2']

Simply insert this under the last piece of code you entered

Last edited by Maffo : 11-07-2006 at 11:18 PM.
Reply With Quote
(#9)
Old
Chaslie Chaslie is offline
Moderator
Chaslie is on a distinguished road
 
Posts: 494
Join Date: Mar 2006
Location: Great Ocean Road - Australia
Default 11-07-2006, 11:23 PM

Thanks for that - fantastic.

(Sorry to confuse with the editored post, Maffo - the reason I couldn't see it in categories because I was picking a category where I hadn't actually added in extra field content in the listing itself - dumb!)


Chaslie
V3.1.4 dev
mods.auscity.com
AUSCITY
Reply With Quote
(#10)
Old
Maffo Maffo is online now
Senior Member
Maffo is on a distinguished road
 
Posts: 545
Join Date: Mar 2006
Location: English in Argentina
Send a message via MSN to Maffo
Default 11-07-2006, 11:27 PM

I'll let you off this time and only because I like charlie brown and snoopy, had you been tweety pie it may have gotten quite violent!!

This is a very useful piece of code.

Maybe as a suggestion we should have a section on this forum specifically for scraps of code. I have got so many for this piece of kit!!!
Reply With Quote


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Top Listings sbuell20 v3.1 Questions & Support 0 09-02-2006 12:11 PM
Displaying extra field in Search and category listings Bucketman v3.0 Questions & Support 3 04-26-2006 09:48 AM



Powered by vBulletin® Version 3.6.3
Copyright ©2000 - 2007, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com