By Alexandre Cayer on Friday, 20 November 2015
Posted in Technical Issues
Replies 3
Likes 0
Views 597
Votes 0
Hi Guys,

I'm trying to overlap my country and region database for my component with yours so I can test if service is in the same country as registered user.

I tried a:
$my     = Foundry::user();
print_r($my->getFieldValue("address"));


and the country and region from table #__social_regions seems only to integrate the actual name in the address...

Since my site is multi-language, compare the string doesn't seems to work since the language seems only in english. (the country custom field however does provide the id of the country but there isn't a region custom field plus it would kind of not make sense to ask question twice).

Since I really want to be able to display services of the country and region from which the user is from, I need a hand to be able to fetch the proper country id and region id.

Thanks !

Alex
Hey Alex,

I am sorry of the delay of this reply,

If you would like your country and state name can be support multilingual, it would be best you modify with your all the country and state name to be language string, so that you can override these language string into Joomla language manager, so these country and state name will be get translated to your site language.

For example :
#1. Open this table `#__social_regions` and modify the `name` columns data (Refer attached screenshot 1)
#2. Translate these language string from your language ini file (screenshot : http://screencast.com/t/ncR8KX7gy )
E.g.
JoomlaFolder\language\overrides\en-GB.override.ini
JoomlaFolder\administrator\language\overrides\en-GB.override.ini

#3. Download my attached 2 file into your site
JoomlaFolder\media\com_easysocial\apps\fields\user\address\themes\default\content.php
JoomlaFolder\administrator\components\com_easysocial\themes\default\regions\default.php


You can refer the result on my attached second/3rd screenshot below.

Note : If you follow my instruction above, you must do backup for this table `#__social_regions` and your custom country/state language string translation file.

Hope this help.
·
Friday, 20 November 2015 18:20
·
0 Likes
·
0 Votes
·
0 Comments
·
Her Arlex,

Thanks for this answer. This would be quite something to maintain. You don't plan to make it as a language token? You have army of translater with transiflex... Doesn't make sense to do it in english alone.

However, if I would like to modify the method of the address custom so it return the country id as it does for country custom field, would you have a suggestion? I would just make a relation table on IDs and left the name behind and only fetch name with first table!

Otherwise, if chstom field for country and address are use, the first should change the second which is read-only. That could be a could universal solution:

On ready, check if address field present, if yes, it changes address prop readonly to true and adds an onupdate function so that adress country html = this. Html
·
Friday, 27 November 2015 14:07
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Alex,

I am really sorry for the delay of this reply,

We will see what we can improve this in the future.

If you would like to get the state value, you can try using the following code and see how it goes?

$my = Foundry::user();
print_r($my->getFieldData("address")["state"]);
·
Monday, 30 November 2015 19:54
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post