68 Classifieds Forums

68 Classifieds Forums (http://www.68classifieds.com/forums/)
-   Modules / Plugins / Modifications (http://www.68classifieds.com/forums/modules-plugins-modifications/)
-   -   MODIFICATION: Display your extra fields on the showlistings.tpl page (http://www.68classifieds.com/forums/modules-plugins-modifications/4387-modification-display-your-extra-fields-showlistings-tpl-page.html)

cwp 03-02-2008 11:26 PM

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.

Eric Barnes 04-11-2008 10:08 AM

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.

cwp 04-11-2008 11:35 AM

which version was it added in? And I'll change my post

Eric Barnes 04-11-2008 11:36 AM

Sorry forgot to mention that. Starting with v4.0.1 that function is now added.

cwp 04-11-2008 04:23 PM

Quote:

Originally Posted by suzkaw (Post 22520)
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.

anna245 04-22-2008 12:16 PM

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?

Lhotch 04-22-2008 12:23 PM

Quote:

Originally Posted by anna245 (Post 22873)
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?

Eric Barnes 04-22-2008 12:30 PM

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.

cwp 04-22-2008 01:15 PM

Quote:

Originally Posted by suzkaw (Post 22877)
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.

anna245 04-22-2008 01:19 PM

Thanks! It works now!:)


All times are GMT -4. The time now is 05:46 PM.

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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22