lcollong
FabriKant d'applications web
Hi,
Related to this post, I've done an interesting test for which I'd like to have your opinion.
I'm in the process to replace the use of core Dropdown, Radio and Checkbox elements by their "joined" counterpart in order to avoid storing user data in the core fabrik tables and ease statistics built based on these kind of fields.
So I have a "referential table" used to store the labels of, saying 3 dropdown elements rendered as DBjoin. This table has "id", "element_id", "label", "published" and "order" columns. I use "element_id" to limit the dbjoin to display only the appropriate values of a given dropdown element. "Id" is the "value" stored in the main DB table for each dropdown.
In most of the cases, we use DBjoin elements to display fields from a relevant table. There are no reasons to translate these fields. For example, in you have a list of cars with a trade element joined to an external list of trademarks, no reason to translate the labels.
But for a "referential table" used to store labels such I've exposed previously, there is a big interest to translate them. For examples, if these 3 dropdown relate to "body shape", "type of engine" and "color", translate these labels make sense for a a multi-language site.
There are several ways to deal with translations as explained by several Fabrik's powerusers. However the standard J! language override feature sounds to me very comfortable and efficient. It works very well for core Fabrik's dropdown labels but not for DBjoin ones.
So I dig in the source and copy the following lines before the "switch" instruction around line 1360 of the plugins/fabrik_element/databasejoin/databasejoin.php file :
And it does the trick ! whenever I change the language, my DBjoin dropdown shows the right translation.
I'm sure this is not the right place to do it (view or model ?) and I think it should be associated with an individual element parameter to actually override or not (default). Most of the case it's not a good idea to translate nor to "loose" CPU time of doing it.
Is this sound doable ? I'm pretty sure this complex element has "side effect" (concat label, access level, detail rendering, filter, etc....) that may make this enhancement more complicated than I expect.
Any thoughts ?
Related to this post, I've done an interesting test for which I'd like to have your opinion.
I'm in the process to replace the use of core Dropdown, Radio and Checkbox elements by their "joined" counterpart in order to avoid storing user data in the core fabrik tables and ease statistics built based on these kind of fields.
So I have a "referential table" used to store the labels of, saying 3 dropdown elements rendered as DBjoin. This table has "id", "element_id", "label", "published" and "order" columns. I use "element_id" to limit the dbjoin to display only the appropriate values of a given dropdown element. "Id" is the "value" stored in the main DB table for each dropdown.
In most of the cases, we use DBjoin elements to display fields from a relevant table. There are no reasons to translate these fields. For example, in you have a list of cars with a trade element joined to an external list of trademarks, no reason to translate the labels.
But for a "referential table" used to store labels such I've exposed previously, there is a big interest to translate them. For examples, if these 3 dropdown relate to "body shape", "type of engine" and "color", translate these labels make sense for a a multi-language site.
There are several ways to deal with translations as explained by several Fabrik's powerusers. However the standard J! language override feature sounds to me very comfortable and efficient. It works very well for core Fabrik's dropdown labels but not for DBjoin ones.
So I dig in the source and copy the following lines before the "switch" instruction around line 1360 of the plugins/fabrik_element/databasejoin/databasejoin.php file :
PHP:
foreach ($tmp as &$label_tmp)
{
$label_tmp->text = FText::_($label_tmp->text);
}
And it does the trick ! whenever I change the language, my DBjoin dropdown shows the right translation.
I'm sure this is not the right place to do it (view or model ?) and I think it should be associated with an individual element parameter to actually override or not (default). Most of the case it's not a good idea to translate nor to "loose" CPU time of doing it.
Is this sound doable ? I'm pretty sure this complex element has "side effect" (concat label, access level, detail rendering, filter, etc....) that may make this enhancement more complicated than I expect.
Any thoughts ?