Hi!
Guys, I'd love to know exactly how you manage to get the translation of of a multiselect listbox TV.
Nevertheless I found a solution which doesn't seem nice but works.
Here it is
So I created a namespace for my website and then 2 entries with the same name: "myTVContent" (one for "en" and the other for "fr")
At first I just then put [[!%myTVContent? &namespace=`myNamespace` &topic=`default`]] in the input value for the multiselect listbox TV
but it wouldn't process my lexicon , so I use @EVAL like this:
@EVAL $modx->lexicon->load('myNamespace:default');return $modx->lexicon('myTVContent');
would like to know what you think about this solution.
Now if I want to add new categories, I will have to add it at the end and be careful that both translation have similar elements separated by ||.
regards
<select> <option>[[%namespace.1]]</option> <option>[[%namespace.2]]</option> <option>[[%namespace.3]]</option> </select>
<?php
$modx->lexicon->load('myNameSpace:default');
switch($input){
case '1': $categoryName = $modx->lexicon('MyOption1'); break;
case '2': $categoryName = $modx->lexicon('MyOption2'); break;
}
echo $categoryName;
Hi, thanks for your fast reply!
Yes, I create a namespace and filled in some entries in the default topic.
I do not have a plugin for what I need to do, how and where can I load the onHandleRequest to benefit the format without the parameters?
Indeed, I also added the index number (myOption==1||mySecondOption==2 ...), I found that what was saved in modx when selecting among a list of options is the value. So when I save the same option in two different language context, I had to different options saved, but they are the same, just in 2 different language.
For now what I did is creating a snippet that convert the number to the category name like this:
[[+theNumberOfMyOption:numToCategoryName]]
the snippet numTocategoryName :
<!--?php $modx--->lexicon->load('myNameSpace:default'); switch($input){ case '1': $categoryName = $modx->lexicon('MyOption1'); break; case '2': $categoryName = $modx->lexicon('MyOption2'); break; } echo $categoryName;
filled the entries (MyOption1, MyOption2) in the 2 language I need.
And let Babel do the cultureKey detection
But I still want to know though the onHandleRequest
And what do you think of my solution? Besides, was wondering if it is ok that the lexicon->load is beeing called several times on the same page?
<?php
if($modx->context->get('key') == 'mgr' || $modx->event->name != 'OnHandleRequest') { return ''; }
$modx->lexicon->load('myNameSpace:default');
ok nevermind for the onHandleRequets, I think I got, just re-read the previous post
if($modx->context->get('key') == 'mgr' || $modx->event->name != 'OnHandleRequest') { return ''; }$modx->lexicon->load('myNameSpace:default');