Support Forums

MODIFICATION: Display your extra fields on the showlistings.tpl page

This is a discussion on MODIFICATION: Display your extra fields on the showlistings.tpl page within the Modules / Plugins / Modifications forums, part of the Developer Forums category; You must have the developer edition in order to do this modification. Put this code somewhere in your includes/classes/kernal/listings.php page. ...


Go Back   68 Classifieds Forums > Developer Forums > Modules / Plugins / Modifications

Reply
 
Thread Tools Display Modes
Old 03-02-2008, 11:26 PM   #1
Senior Member
 
cwp's Avatar
 
Join Date: Jun 2007
Posts: 296
Rep Power: 22
cwp is a jewel in the rough
Default MODIFICATION: Display your extra fields on the showlistings.tpl page

You must have the developer edition in order to do this modification.

Put this code somewhere in your includes/classes/kernal/listings.php page. I added it to the
very end.

If you have version 4.0 start here. If you have version 4.01, please skip this step and continue with the next one.
PHP Code:
function getExtraField($id,$fieldid)
    {
        global 
$db;
        
$sSQL "SELECT sValue FROM ".PREFIX."products_fields WHERE pID='".$id."' AND fID=".$fieldid;
        
$result=$db->query($sSQL);
        if ( 
$result->isError() )
        {
            
trigger_error('Listing::getListing: Unable to fetch listing');
            return 
false;
        }
        if ( 
$result->size()>)
        {
            
$rs=$result->fetch();
            
$value $rs['sValue'];
        }
        
$result->freeResult();
        return 
$value;
    } 
As a reminder, if you have version 4.01, you will start here:

Find this:
PHP Code:
$row['status']=$row['display']; 
Add this right after it:
PHP Code:
$row['extrafield'] = $this->getExtraField($row['id'], 4); 
Keep in mind the number 4 needs to come from the administration extra fields. This is the id of the extra field you want to get.
Replace the number 4 with your field id which you can get in administration, under extra fields.To add another extra field just it.


On Showlistings.tpl add this right where you want it to show up:
Code:
{$entry.extrafield}
If you had added multiple, it would be like this, and so on.
Code:
{$entry.extrafield2}
Credit goes to suzkaw.
__________________
Version 4.0.3 Developer

Last edited by cwp; 04-22-2008 at 01:14 PM.
cwp is offline   Reply With Quote
Old 04-11-2008, 10:08 AM   #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

I wanted to follow up on this thread and say that first function is now part of the file. So it will be already included.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 04-11-2008, 11:35 AM   #3
Senior Member
 
cwp's Avatar
 
Join Date: Jun 2007
Posts: 296
Rep Power: 22
cwp is a jewel in the rough
Default

which version was it added in? And I'll change my post
__________________
Version 4.0.3 Developer
cwp is offline   Reply With Quote
Old 04-11-2008, 11:36 AM   #4
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

Sorry forgot to mention that. Starting with v4.0.1 that function is now added.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 04-11-2008, 04:23 PM   #5
Senior Member
 
cwp's Avatar
 
Join Date: Jun 2007
Posts: 296
Rep Power: 22
cwp is a jewel in the rough
Default

Quote:
Originally Posted by suzkaw
Sorry forgot to mention that. Starting with v4.0.1 that function is now added.
Thanks, I edited the original post with steps for each version.
__________________
Version 4.0.3 Developer
cwp is offline   Reply With Quote
Old 04-22-2008, 12:16 PM   #6
Member
 
Join Date: Apr 2008
Posts: 51
Rep Power: 13
anna245 is on a distinguished road
Default error on listings.php

I inserted $row['extrafield'] = getExtraField($row['id'], 4); replacing the "4" with the id number on the listings.php page and when I do a search on the site, the view listings page is blank with this error showing up.

Fatal error: Call to undefined function: getextrafield() in the listings.php page.

Any suggestions on how to fix?
anna245 is offline   Reply With Quote
Old 04-22-2008, 12:23 PM   #7
curmudgeon
 
Join Date: Mar 2006
Posts: 5,342
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 anna245
I inserted $row['extrafield'] = getExtraField($row['id'], 4); replacing the "4" with the id number on the listings.php page and when I do a search on the site, the view listings page is blank with this error showing up.

Fatal error: Call to undefined function: getextrafield() in the listings.php page.

Any suggestions on how to fix?
What version of 68C are you running? As Eric stated above, the getextrafield function was added until v4.0.1. Are you running the initial 4.0.0?
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline   Reply With Quote
Old 04-22-2008, 12:30 PM   #8
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

It does appear to have an error in the instructions. I have just modified them to be correct. Basically where you have:
$row['extrafield'] = getExtraField($row['id'], 4);

Should be:
$row['extrafield'] = $this->getExtraField($row['id'], 4);

Also keep in mind the number 4 needs to come from the administration extra fields. This is the id of the extra field you want to get.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 04-22-2008, 01:15 PM   #9
Senior Member
 
cwp's Avatar
 
Join Date: Jun 2007
Posts: 296
Rep Power: 22
cwp is a jewel in the rough
Default

Quote:
Originally Posted by suzkaw
It does appear to have an error in the instructions. I have just modified them to be correct. Basically where you have:
$row['extrafield'] = getExtraField($row['id'], 4);

Should be:
$row['extrafield'] = $this->getExtraField($row['id'], 4);

Also keep in mind the number 4 needs to come from the administration extra fields. This is the id of the extra field you want to get.

Thanks for the heads up. I fixed the post.
__________________
Version 4.0.3 Developer
cwp is offline   Reply With Quote
Old 04-22-2008, 01:19 PM   #10
Member
 
Join Date: Apr 2008
Posts: 51
Rep Power: 13
anna245 is on a distinguished road
Default

Thanks! It works now!
anna245 is offline   Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
MODIFICATION: Display extra fields separately. cwp Modules / Plugins / Modifications 2 05-30-2008 03:20 PM
Display extra fields on showlistings.tpl cwp Technical Support 9 03-03-2008 09:52 AM
Display extra fields by themselves? cwp Technical Support 3 02-22-2008 04:34 AM


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


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