|
|
#1 |
|
Member
Join Date: Aug 2008
Posts: 68
Rep Power: 5 ![]() |
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 |
|
|
|
|
|
#2 |
|
68 Classifieds Staff
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,845
Rep Power: 111 ![]() |
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 |
|
|
|
|
|
#3 |
|
Graphic / Web Desginer
Join Date: Nov 2008
Location: London, England
Posts: 73
Rep Power: 3 ![]() |
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. |
|
|
|
|
|
#4 | |
|
Moderator
Join Date: Mar 2006
Posts: 4,225
Rep Power: 103 ![]() ![]() |
Quote:
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 |
|
|
|
|
|
|
#5 |
|
Graphic / Web Desginer
Join Date: Nov 2008
Location: London, England
Posts: 73
Rep Power: 3 ![]() |
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? |
|
|
|
|
|
#6 |
|
Moderator
Join Date: Mar 2006
Posts: 4,225
Rep Power: 103 ![]() ![]() |
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 |
|
|
|
|
|
#7 |
|
Graphic / Web Desginer
Join Date: Nov 2008
Location: London, England
Posts: 73
Rep Power: 3 ![]() |
Thanks for your help Larry.
|
|
|
|
|
|
#8 | |
|
Moderator
Join Date: Jan 2007
Location: Pennsylvania, USA
Posts: 1,390
Rep Power: 41 ![]() ![]() |
Quote:
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 |
|
|
|
|
|
|
#9 |
|
Graphic / Web Desginer
Join Date: Nov 2008
Location: London, England
Posts: 73
Rep Power: 3 ![]() |
Thanks Mike.
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
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 |