Go Back   Mosets Community > Archives > Mosets Hot Property 1.0 > Hot Property 1.0 Tips and Tricks

Thread Tools Search this Thread Display Modes
Old 10-27-2010, 05:35 PM
jeanpaulbraud jeanpaulbraud is offline
Join Date: Jan 2009
Posts: 16
Default Extra Field - select list - get values from database


I have created a extrafield 'City' with Type: select list. I want that field elements to be taken from database. I mean, to be loaded all cities where is at least one property listed.

Can anybody help me with this? I have write the select statement to extract the cities from database, but I don't know where to put this select statement in the code, or how to relate it with my select box.

Any help is appreciated.
Thank you
Old 10-28-2010, 04:47 AM
gray gray is offline
Join Date: Apr 2006
Posts: 901

It's a rather complected task. Here I just show you basic steps which should be taken.

1. First of all it's easier when the city is a core field, let's use core field "suburb". You need to extract list of all cities already published (doc)
PHP Code:
$db =& JFactory::getDBO();
$query "SELECT DISTINCT suburb FROM #__hp_properties WHERE published = 1";
$rows $db->query(); 
2. put the received values into generic list, option value and text will be the same (doc#1, doc#2)
PHP Code:
foreach ($rows as $r)
$val   $r;
$text  $r;
$options[] = JHTML::_('select.option'$rJText::_($r));
$cities JHTML::_('select.genericlist'$options$namenull'value''text'); 
3. on property details page replace standard rendering procedure with $cities variable

Still, one problem will remain - user would not be able to ADD new cities, only to select from existing in the list. As a way out an input box for new values could be added, but this complicates the task even more.

In other words, the task is not an easy one, and should be proceeded only if it's VERY required to have such an feature.
4HP: Slideshow Module New!
Old 10-28-2010, 03:31 PM
jeanpaulbraud jeanpaulbraud is offline
Join Date: Jan 2009
Posts: 16

Thank you for your great help. I will try to implement and let you know if I succeed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Not show info from extra field if no info is in the field ssnobben Discussions, Troubleshooting and Problems 2 08-22-2011 01:26 PM
search extra field AND/OR gborprohszka Discussions, Troubleshooting and Problems 2 05-06-2009 07:56 PM

All times are GMT +8. The time now is 09:18 AM.

Copyright © 2005-2010 Mosets Consulting

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.