I try to explain and add more results from tests. The environment is a multi-lingual site (with a parent/child content type, I will add it later) where the multilingual is done not with item cloning as in Joomla but using Seblod with JTEXT translations for fixed-value fields and by cloning text-value fields and restricting their output with Seblod language restriction.
Now the point is: how to set metadata, like metadescription, in this environment?
It's not possible to clone fields like the default art_metadescription to use the default for English and another one, custom, for a second language and restrict them by language. It does not work since these field are treated in a special way, their output must go to the hidden head part of the page, so you cannot create a new metadescription field and make it show its value in the head, it will show up in the body, not as a metadata.
Alternatives?
- Maybe using just the standard metadescription field and fill its value to needed language-dependant values in a beforeRender field, but it does not work ($fields['art_metadesc']->value = ''; has no effect).
- Maybe setting the metadescription through Joomla API (setDescription() function call): that partially works, i.e. you can set the metadesc of an article as long the associated menu does not have any metadescription, even if in Joomla the article metadata should win over menu metadata. There is a problem/bug that the menu metadesc overrides article metadesc and it shouldn't.
- Maybe using custom PHP code in some field: using for example the useful Sourcerer plugin from RegularLabs, you can write PHP code directly in a HTML place, so we can use the Seblod HTML typography of a field and put the code there. Tried, the code is executed, metadescription seems to be added (the $document object returned by the setDescription call does contain the metadescription) but there is no track of it on the final rendered page. Seblod probably overwrites later the head.
- Seblod 3.16 provides a "override metadescription" option in the content view to ovveride metadesc taking the value from another set of fields EN/FR/.... That solution works but not on parent content where there is parent/child relation, so in this case you should clone these fields in all the child contents. Probably there is no solution of this limitation since actually Seblod uses the child configuration and not the parent one.
So, how to to do it easily? I have hopes for solution number 2 or 1.
@Klas or the Octopoos team, which is the best way to set metadescription, so important for SEO, in a multilanguage Seblod-powered site?
Thanks a lot
Giuse