Support Forums


Go Back   68 Classifieds Forums > Help & Support > v4 Questions & Support

Notices

 
LinkBack Thread Tools Display Modes
Old 02-10-2009, 07:21 PM   #1
Member
 
Join Date: Aug 2008
Posts: 68
Rep Power: 5
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   Reply With Quote
Old 02-10-2009, 09:35 PM   #2
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,845
Rep Power: 111
Eric Barnes is a jewel in the rough
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
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-04-2009, 10:32 PM   #3
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 73
Rep Power: 3
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   Reply With Quote
Old 05-05-2009, 08:38 AM   #4
Moderator
 
 
Join Date: Mar 2006
Posts: 4,225
Rep Power: 103
Lhotch is just really niceLhotch is just really nice
Default

Quote:
Originally Posted by DGiscombe View Post
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.
(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-05-2009, 10:31 AM   #5
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 73
Rep Power: 3
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   Reply With Quote
Old 05-05-2009, 10:33 AM   #6
Moderator
 
 
Join Date: Mar 2006
Posts: 4,225
Rep Power: 103
Lhotch is just really niceLhotch is just really nice
Default

Quote:
Originally Posted by DGiscombe View Post
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.
(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-05-2009, 10:51 AM   #7
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 73
Rep Power: 3
DGiscombe is on a distinguished road
Default

Thanks for your help Larry.
DGiscombe is offline   Reply With Quote
Old 05-05-2009, 11:39 AM   #8
Moderator
 
 
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 1,390
Rep Power: 41
Mike-N-Tosh is just really niceMike-N-Tosh is just really nice
Default

Quote:
Originally Posted by DGiscombe View Post
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
v3.1.10 Developer IndianaPC.org - A community website
Sandbox v4.0.9, 4.1
Templates, Mods & Docs for sale | My blog with much content for 68 Classifieds.
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   Reply With Quote
Old 05-05-2009, 05:13 PM   #9
Graphic / Web Desginer
 
Join Date: Nov 2008
Location: London, England
Posts: 73
Rep Power: 3
DGiscombe is on a distinguished road
Default

Thanks Mike.
DGiscombe 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
Display Image for Extra Field within Listings nagrap2 v4 Questions & Support 2 02-10-2009 01:18 PM
MODIFICATION: Display your extra fields on the showlistings.tpl page cwp v4 Modules / Modifications 23 01-12-2009 12:22 PM
Display extra fields on showlistings.tpl cwp v4 Questions & Support 9 03-03-2008 08:52 AM
Extra field display help CHRD v3.1 Questions & Support 4 11-27-2007 10:05 AM
Clickable Extra Field to showlistings.tpl.php GSP v3.1 Questions & Support 7 06-14-2007 09:07 AM


All times are GMT -4. The time now is 02:28 AM.


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