248 Posts
Giuse
5 years ago
5
Topic

in Joomla setting Metadata article assignment values take priority on menu assignment.

In Seblod if you set for example metadescription with setDocument in a beforeRender field, the value is shown only if menu metadescription is empty, otherwise the menu metadescription is always shown and not the article one.

Is it a bug?

BTW I am setting metadescription dynamically in a multilingual site, so usage of Article - metadescription field is not feasible, that field seems to handle priority correctly.

Thanks 

Get a Book for SEBLOD
248 Posts
Giuse
5 years ago
4
Level 1

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?

  1. 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).
  2. 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.
  3. 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.
  4. 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

4229 Posts
Kadministrator
5 years ago
3
Level 2

Sure it is possibile to " to clone fields like the default art_metadescription" - just make another field with the same storage and restrict it. But if you are using code you should be able to set this fields value from beforeRender or just leave metadesctiption field  empty and set it from beforeRender. Why is menu metadescription a problem? Just leave it empty and set it all at one place in beforeRender?

248 Posts
Giuse
5 years ago
2
Level 3

No Klas, I tried before to write: you cannot clone a field whose value is handled differently since its value is for the head and not for the body. Try to create a field with Standard / Article / metadesc storage and that field will be shown as a normal field and will not be used to populate the head tag of the page, so it's not a way to go.

The problem in using beforeRender is the conflict with the menu metadesc: the menu page (a Seblod list) needs a specific metadescription (like "List of items of type X") which is set in the Seblod menu item, while each item of the list has a specific metadesc that I tried to set with beforeRender, but if I set the metadesc of the menu page, then it overrides metadesc of articles.

Maybe Seblod code to fill metadescription of the page does not check priority of article metadesc? The PHP code setDescription put in a standard Joomla article works fine (i.e. article takes priority over menu).

thanks

248 Posts
Giuse
5 years ago
1
Level 4

Hi, should I open an issue on github to check the behavior of metadescription priority of a way to duplicate metadescription field?

thanks

Giuse

4229 Posts
Kadministrator
5 years ago
0
Level 5

This is just a  matter of execution order in Joomla&Seblod - basically whatever comes last, wins and since there is not much Seblod can do about it, if Joomla sets description after it has been set by Seblod it will be overwritten. If you need to assure that your description always wins you will need to set it from site template as those are executed at the very end. 

Get a VIP membership