Search the FirstSpirit Knowledge Base
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
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
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
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:
Within st_list i chose another section template (st_download_list_product), which has, again,
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
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é
Hi Rene,
I am using project languages.
I just need english content on the, for example, French site...
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
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,
Sebastian
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