MODX Community

Output modifier salad in 2 languages

Again unable to make output modifiers to work
(real lack of sample in the official doc by the way)

I need to display a string that comes from previous process in a place holder BUT for some reason this string must have its value changed is one case.
this [[+nomFacet]] is used in a little tpl, that is call multiple times in each regarding pages (in some filtering buttons blocks)

I choose to set a specific new i18n lexicon entries (fr + eng) for this alternate value.

The logic is:
if [[+nomFacet]] is=Particle size or is= Taille particule (comes in one or another language)
then show the alternate value from the lexicon
[[%i18n.Facet_dim_part_[[+thisParent]]? &language=[[++cultureKey]] &namespace=i18ncustom]]

else
use the originale value of the place holder [[+nomFacet]]
2h30 on it, I abdicate… can’t definitively understand the :default:hide:show is=:or:is=:else=`` salad bar.

Thank you.

You should try to avoid having logic like that within the templates.
Maybe. you could handle the logic there, where you set the placeholder for [[+nomFacet]]

hi
again if modx proposes output modifier and no one can use them… something is wrong

Maybe this works:

[[+nomFacet:is=`Particle size`:or:is=`Taille particule`:then=`[[%i18n.Facet_dim_part_[[+thisParent]]? &language=`[[++cultureKey]]` &namespace=`i18ncustom`]]`:else=`[[+nomFacet]]`]]

thank you

this seems to gives some results, but unfortunately never grab the i18n string when it should (always the original place holder value.
Tested with a basic string instead of the lexicon call: same
As I also put the[[+nomFacet]] in the code I can see the values it takes.
this prooves the test does not do its jobs as intented…

I can’t reproduce your problems. Maybe it is a caching issue.
Do you gain any new insights when you execute this testing code:

nomFacet (cached):|[[+nomFacet]]|<br>
nomFacet (uncached):|[[!+nomFacet]]|<br>
thisParent (cached):|[[+thisParent]]|<br>
thisParent (uncached):|[[!+thisParent]]|<br>
translation (cached):|[[%i18n.Facet_dim_part_[[+thisParent]]? &language=`[[++cultureKey]]` &namespace=`i18ncustom`]]|<br>
translation (uncached)|[[!%i18n.Facet_dim_part_[[!+thisParent]]? &language=`[[!++cultureKey]]` &namespace=`i18ncustom`]]|<br>
if-clause (cached):|[[+nomFacet:is=`Particle size`:or:is=`Taille particule`:then=`translation`:else=`original text`]]|<br>
if-clause (uncached):|[[!+nomFacet:is=`Particle size`:or:is=`Taille particule`:then=`translation`:else=`original text`]]|<br>

Thanks a lot.

I think I’ve tried some I’ll give another tr on Monday. But the solution will probably come from de php inside our specific snippet that produce a lot of those stuff.

Output modifiers tend to fail when they reach a certain level of complexity, and/or nesting. The problem is that parts of the modifier may not have been parsed at the time that other parts need them.

A custom snippet that replaces all the modifiers is almost always faster and more reliable.