68 Classifieds Forums

68 Classifieds Forums (http://www.68classifieds.com/forums/index.php)
-   v3.1 Questions & Support (http://www.68classifieds.com/forums/forumdisplay.php?f=19)
-   -   Showlistings2.tpl.php help (http://www.68classifieds.com/forums/showthread.php?t=1902)

CHRD 11-08-2006 06:11 AM

I will not be using any of the "User Registration Fields"

these are the 'additional fields' IDs

Location: id - 9, called x1
Sleeps: id - 11, called x1
Type: id - 5, called x1
Price: id - 7, called x1
state: id - 10, called x3
country: id - 8, called x1

is it possible to have
cheap flights to "state, country"

Chaslie 11-08-2006 04:33 PM

Question - whereabouts in 'administrationm' did you add these fields? Please be very specific.

Also, what does 'called x3' mean? .... as in ....'state: id - 10, called x3'

CHRD 11-08-2006 08:24 PM

I made these fields up in /administration/fields.php.
'state: id - 10, called x3', means I would like to use state data 3 times on showlistings2.tpl.php
like for

cheap travel insurace for "state"
cheap car hire in "state"
cheap flight to "state, country"
credit card trasfur
Email A Friend

"called X3" means I would like to insert state info 3 times on the same page

Chaslie 11-08-2006 09:32 PM

Ok - now I understand - these are called 'extra fields'.

Open up the files category.php, searchresults.php and toplistings.php. They are situated in your root directory of the classifieds script.

In these files you will see this:

Code:

//now get the images
Directly above it in each file, add this:

Quote:

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

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

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

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

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

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

Have highlighted in red (above) what is actually added for each field being used. The code above is for your 6 fields that you identified to be included in showlistings2.


Now open up showlistings2.tpl.php.

Where you wish to have 'location' displayed, add this: {$entry.mafExtralocation}

Where you wish to have 'sleeps' displayed, add this: {$entry.mafExtrasleeps}

Where you wish to have 'type' displayed, add this: {$entry.mafExtratype}

etc, etc.

Let's know how you go. I'm sure many others will use this modification - it's very simple (when you know how) and very powerfull. Thanks to maffo for the help with this one.

CHRD 11-09-2006 09:35 AM

Iv got the designer copy of 68, I need to upgrade or can you do it with out developer copy??

thanks for your help and time, this is a HOT HACK

Maffo 11-09-2006 10:42 AM

An upgrade is the only way im afraid but worth every penny.

Lhotch 11-09-2006 10:42 AM

I have one site ive been working on which is largely informational and I have nearly 70 fields that I want people to be able to see "at a glance" so I wanted them on the showlisting level. What I did was used the following code to grab all the extra fields. It then adds them to the current $row array with a key that equals their fieldname. The $row array is later assigned to $result and passed to the template.

here is my little code snipped to get and pass the extra fields.

Code:

$extra=array();
                $sSQL = "SELECT f.fID,sValue FROM ".PREFIX."products_fields AS p, `".PREFIX."fields` AS f WHERE p.pID='".$row['id']."' AND f.fSeen='Y' AND p.fID=f.fID ORDER BY f.fOrder ASC";
                $eresult=$db->query($sSQL);
                $i=0;
                while ($rs=$eresult->fetch())
                {
                        $sql="SELECT fID,fName,fType FROM `".PREFIX."fields` WHERE fID='".$rs['fID']."' AND fSeen='Y' ORDER BY fOrder ASC";
                        $eresult2=$db->query($sql);
                        $rs2=$eresult2->fetch();
                        $fieldname=str_replace(" ", "_", $rs2['fName']);
                        $row[$fieldname]=$rs['sValue'];
                                   
                } // end while


Maffo 11-09-2006 10:51 AM

Now thats efficiency!

Thats how it should be written when wanting more than one field.

70 extra fields???:confused: :confused:

CHRD 11-09-2006 10:56 AM

Hi Larry, on what pages did you use this code, do I still need the upgrade

Also if I upgrade to the developer 68 what files do I need to save, So I dont loose all the changes Iv made so far

Lhotch 11-09-2006 11:01 AM

Quote:

Originally Posted by Maffo (Post 10127)
Now thats efficiency!

Thats how it should be written when wanting more than one field.

70 extra fields???:confused: :confused:

Ya, its a lot of extra fields but the site is mainly just an informational database. I want people to be able to see and compare and even change the sort order like default at just a glance without having to go into each ad to see all the little details.

Im doing away with the left nav and will be using a DHTML menu across the top, ive just been too busy to redo the layout.


Quote:

Originally Posted by CHRD (Post 10128)
Hi Larry, on what pages did you use this code, do I still need the upgrade

Also if I upgrade to the developer 68 what files do I need to save, So I dont loose all the changes Iv made so far

That is PHP code so would require the developer edition.

It would need to be added to the same 3 files Chaslie mentioned (ie category.php, searchresults.php and toplistings.php)


All times are GMT -4. The time now is 10:55 PM.

Powered by vBulletin® Version 3.6.3
Copyright ©2000 - 2007, Jelsoft Enterprises Ltd.