Support Forums

Display Extra Field in Showlistings.php

This is a discussion on Display Extra Field in Showlistings.php within the Technical Support forums, part of the Technical Support Forums category; Hi, I would like to display one of my extra fields with id 4 within showlistings.php. I have seen a ...


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 02-10-2009, 08:21 PM   #1
Customer
 
Join Date: Aug 2008
Posts: 80
Rep Power: 11
nagrap2 is on a distinguished road
Default Display Extra Field in Showlistings.php

Hi,

I would like to display one of my extra fields with id 4 within showlistings.php. I have seen a function in \includes\classes\kernel\listings.php that says "allows you to pull out extra fields and dislay them in showlistings."

function getExtraField($id,$fieldid)

The comments also say you call it as follows:

Example: If you have an extra field with the id of 2:
<code>$row['extra']=$this->getExtraField($row['id'], 2);</code>

Only question is how do I call it and from which file? Is it from within the showlistings.tpl?

Thanks in advance...
__________________
Many Thanks,

Nagrap2

Developer Version 4.1
nagrap2 is offline  
Old 02-10-2009, 10:35 PM   #2
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,493
Rep Power: 132
Eric Barnes is just really nice Eric Barnes is just really nice
Default

In v4.0.x you would use that code in the same Listings class. For showlistings it uses function getAllListings() then in that same function way down it has something like this:
while ($row=$result->fetch())
{
$row['id']=$row['id'];

After the $row['id'] add you new variable:
$row['myvar'] = $this->getExtraField($row['id'], 2);

In v4.1 we have a new smarty plugin to make this easier:
http://www.68classifieds.com/documen...et_extra_field
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline  
Old 05-04-2009, 11:32 PM   #3
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 77
Rep Power: 10
DGiscombe is on a distinguished road
Default

Hi,

I'm using version 4.1.2. Could you show me how you code the get_extra_field into the showlistings.tpl?

e.g. <th scope="col">...</th>

I'm a bit confused.
DGiscombe is offline  
Old 05-05-2009, 09:38 AM   #4
curmudgeon
 
Join Date: Mar 2006
Posts: 5,340
Rep Power: 132
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by DGiscombe
Hi,

I'm using version 4.1.2. Could you show me how you code the get_extra_field into the showlistings.tpl?

e.g. <th scope="col">...</th>

I'm a bit confused.
Im confused as well because I dont understand your exact point of confusion.

If you look at the showlistings.tpl template you can see where the table header is created and below that the smarty that loops over the array of data that contains all the ads for the page. Each iteration of the array is a row in the table and a new ad.....


{foreach from=$results item="entry"}

the above says to access the array sent from PHP called $results as "entry" and since we are dealing with a multidimensional array each iteration will have additional values accessible by using the array key which is the field name in th case. So if you look for the smaty line above, under it you will see the table row and then smarty logic checks to determine if a field is set to be displayed and if so an opening table data tag and then the smarty call to the variable......

{$entry.title} is the title of the add
{$entry.price|format_money} is the price of the ad followed by a smarty function to format the value into currency. etc etc

the docs for the state if you want to display an extra field for an ad on the showlisting page then use the following smarty plugin...

{get_extra_field id=$entry.id fid=1}

get_extra_field is the name of the plugin

id=$entry.id is the id of the ad and fid=1 means to display extra field with an id of 1.

All you need to do is add an extra data cell to your template in the foreach loop where all the rest of the ad data is displayed and include the plugin line from the documentation. All you have to di is change the value after fid to equal the ID of the extra field you want displayed. You can get that by looking in 68c admin where you created the extra fields to get the id.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 05-05-2009, 11:31 AM   #5
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 77
Rep Power: 10
DGiscombe is on a distinguished road
Default

Ok, sorry for the waste of a long explanation, I was checking a category which had that field empty... Works fine.

And for displaying the name of the extra field, do we have to do that manually?
DGiscombe is offline  
Old 05-05-2009, 11:33 AM   #6
curmudgeon
 
Join Date: Mar 2006
Posts: 5,340
Rep Power: 132
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by DGiscombe
And for displaying the name of the extra field, do we have to do that manually?
Yep, as far as I know. The name of extra fields is stored in a totally different table than the value of the extra field.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 05-05-2009, 11:51 AM   #7
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 77
Rep Power: 10
DGiscombe is on a distinguished road
Default

Thanks for your help Larry.
DGiscombe is offline  
Old 05-05-2009, 12:39 PM   #8
68 Evangelist & Developer
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 2,058
Rep Power: 61
Mike-N-Tosh is just really nice Mike-N-Tosh is just really nice
Default

Quote:
Originally Posted by DGiscombe
And for displaying the name of the extra field, do we have to do that manually?
My modified extra fields smarty plug-in gets the name as well. It also outputs both, if there is a value in the extra field for the listing, otherwise it outputs nothing.

Get it as posted in the forums in this thread.
__________________
Mike-N-Tosh
IndianaPC.org - A community website (v3.1.10 Developer - heavily modified & used as the CMS)
Sandbox [localhost(v3.1.10, v4.0.9, 4.1.10,4.2)] for development and customization
Visit My blog: reviews, tips, tricks, tutorials and my store with Templates, Mods & Docs
Web Hosting | Web Design & Development | 68 Classifieds Customizations
I am not a 68C employee, just a user and try to help out
Mike-N-Tosh is offline  
Old 05-05-2009, 06:13 PM   #9
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 77
Rep Power: 10
DGiscombe is on a distinguished road
Default

Thanks Mike.
DGiscombe is offline  
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
MODIFICATION: Display your extra fields on the showlistings.tpl page cwp Modules / Plugins / Modifications 28 08-06-2009 01:42 PM
Display Image for Extra Field within Listings nagrap2 Technical Support 2 02-10-2009 02:18 PM
Display extra fields on showlistings.tpl cwp Technical Support 9 03-03-2008 09:52 AM


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


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