XF 2.2 Phrases

Old Nick

Well-known member
Hello, 2 questions about phrases when developing an add-on:
  1. How to use the same sentence for several options? For example if we have 10 fields to fill named URL how not to have 10 different sentences with URL? Is it possible ?
  2. What is the point of checking the Cache this phrase globally option ? Could this be the option that solves my first question?
Thanks !
 
If I'm understanding your question correctly, you can do something like this:

Approach 1:
Create a new phrase as follows
1670303156431.webp
And then in your HTML, use it by appending suffix
HTML:
<xf:textboxrow name="url1" label="{{phrase('youaddonid_url')}} 1" />
<xf:textboxrow name="url2" label="{{phrase('youraddonid_url')}} 2" />
<xf:textboxrow name="url3" label="{{phrase('youraddonid_url')}} 3" />
<xf:textboxrow name="url4" label="{{phrase('youraddonid_url')}} 4" />
<xf:textboxrow name="url5" label="{{phrase('youraddonid_url')}} 5" />

Approach 2:
Create a new phrase as follows
1670303314434.webp
And then in your HTML, use it by supplying the number as parameter
HTML:
<xf:textboxrow name="url1" label="{{phrase('youaddonid_url', {'num' : '1'})}}" />
<xf:textboxrow name="url2" label="{{phrase('youaddonid_url', {'num' : '2'})}}" />
<xf:textboxrow name="url3" label="{{phrase('youaddonid_url', {'num' : '3'})}}" />
<xf:textboxrow name="url4" label="{{phrase('youaddonid_url', {'num' : '4'})}}" />
<xf:textboxrow name="url5" label="{{phrase('youaddonid_url', {'num' : '5'})}}" />
 
Thank you @asprin, those clarifications will be useful.
But I was talking about option phrases, those of the ACP. Each option has an identifier which must be unique and therefore I repeat for each same option the same phrase, for example 10 URL fields, myOptionURL1, myOptionURL2, etc... but the sentence is always the same: URL.
Is there something to do in these cases?
Thanks.
 
Back
Top Bottom