Fallback for the content
Author: draganr
Publication Date: 3/29/2018 9:16
Dear All,
I wanna to create a fallback for the content.
I want to use English Page content on the French site.


<CMS_INPUT_TEXT name="st_headline" hFill="yes" singleLine="no" useLanguages="yes">
<LANGINFOS>
<LANGINFO lang="*" label="Headline" description="Insert the section headline."/>
</LANGINFOS>
</CMS_INPUT_TEXT>
then i set up
$CMS_VALUE(masterLang, #global.project.masterLanguage)$
$CMS_VALUE(#global.language, masterLang)$
but no success. Nothing shows up.
Do you have any advice?
Thanks,
Dragan
-
Author: brueder - 3/29/2018 16:50
Hi Dragan,
what you want to achieve is possible. Try this:
$CMS_VALUE(st_headline, default: #global.section.formData.get(#global.project.masterLanguage, "st_headline").get)$
The above code does not handle null values correctly, but is easier to reason about. the below one also handles null values correctly:
$CMS_SET(set_headline, #global.section.formData.get(#global.project.masterLanguage, "st_headline"))$
$CMS_VALUE(st_headline, default: if (!set_headline.isEmpty, set_headline.get))$
If you want to re-use the code, it's a good idea to put it in a render-template.
Does that help you?
Cheers,
Lena
0 -
Author: draganr - 3/30/2018 9:07
Hi Lena,
Ah, almost. You see, by that code i get headline from the "master" section template.
I have one section (st_section_list_with_sub_navigation) which has:
- st_headline
- st_list (FS_LIST)
Within st_list i chose another section template (st_download_list_product), which has, again,
- st_headline
The above code gives me: st_headline from the st_section_list_with_sub_navigation
So, i probably need something like this:
$CMS_VALUE(st_headline, default: #this.formData.get(#global.project.masterLanguage, "st_headline").get)$
But, that does not work.
Thanks for your help. This code helped me for some other stuff.
Kind regards,
Dragan
0 -
Author: rednoss - 4/5/2018 9:38
Hi Dragan,
is there a specific reason why you arrange your forms in CMS_GROUPs (one for each language) instead of using project languages?
Best regards,
René
0 -
Author: draganr - 4/10/2018 13:19
Hi Rene,
I am using project languages.
I just need english content on the, for example, French site...
0 -
Author: pavone - 4/19/2018 10:01
Hello Dragan,
I think you are almost there. In your case #this is a FormData object. Therefore this should work:
$CMS_VALUE(st_headline, default: #this.get(#global.project.masterLanguage, "st_headline").get)$
Regards,
Tim
0 -
Author: sebastianc - 4/30/2018 15:05
Hello Dragan,
do you need further help or did Tim's reply already help you? If so, it would be great if you marked
his reply as "correct answer" so that other community users find the solution easily. If you have
already found a solution by yourself, it would be very kind of you, if you posted it here.
Best regards,
Sebastian0 -
Author: draganr - 5/7/2018 15:04
Hello Tim, Sebastian,
First of all sorry for the late response.
I was pretty busy and i had couple of days off.$CMS_VALUE(st_headline, default: #this.get(#global.project.masterLanguage, "st_headline").get)$
This is the correct answer. Thank you Tim very much.
Best regards,
Dragan
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
7 Kommentare