too complicated for me

eric258

Member
this for me is too complicated, I have a table with all countries in the world, i would like that when a contry is selected in the form, it automatically places the corrresponding flag...; like below. now the flag is managed by the fabrik table logo.... I assume that i ll have to have a db table with all the flags in it?


upload_2016-7-1_17-3-56.png
 
it's be tedious to set up, but you could use a file upload element, and upload each flag sized as you need it. Then just using the placeholder for your upload element should do it.

But test first, with just one, so you know you are doing it right before uploading 120+.

-- hugh
 
thank you hugh but how would the system know how to put the french flag when the user chooses France as a country?
upload_2016-7-1_18-16-17.png
 
is there not a possible approach with a calc element? if france sectected then logo=french flag?
obviously i have no idea on how to do that
 
nick do you have any idea on how this could be achieved? the user choose his contry on the form and the corresponding flags appears on the div template?
 
Ah, I misunderstood. I thought you just had one record per country in a list.

Yes, you could do it as a calc element, but it would depend how your country table and your icon names are "related".

Easiest way would be to have an extra field in your country table which specifies the name of the icon to use. Or, if the table already includes some "file name friendly" code, like a three letter ISO code or whatever, and you can provide the icons with those names, you could use that.

So let me know what data your country table has, whether you can add a field to it, and how your icons are names.

-- hugh
 
hi there ok here is a screenshot of the countries table
upload_2016-7-2_21-18-55.png

the flags are named with the alpha_2 column
upload_2016-7-2_21-26-10.png
 
Last edited:
Code:
$countyId = $data['yourtable___country_raw'];
$countryId = is_array($countryId) ? $countryId[0] : $countryId;
if (!empty($countryId)) {
    $myDb = JFactory::getDbo();
    $myQuery = $myDb->getQuery(true);
    $myQuery->select('alpha_2')->from('countries')->where('id = ' . $myDb->quote($countryId));
    $myDb->setQuery($myQuery);
    $flagIcon = $myDb->loadResult();
    if (!empty($flagIcon)) {
      return '<img src="/path/to/images/' . $flagIcon . '.png" />';
   }
}
return "";

Tweak the element name and path / icon extension as appropriate.

-- hugh
 
That's as far as I can go with free support. If you want to take out a paid sub, I can log in to your site and debug it for you.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top