backdrop-contrib / metatag

Add structured metadata, aka "meta tags", for various pages on your site.
GNU General Public License v2.0
3 stars 15 forks source link

Broken metatag tokens: Error: Call to undefined function token_get_entity_mapping() #112

Closed argiepiano closed 1 year ago

argiepiano commented 1 year ago

Try the following in Devel:

$node = node_load(2);
dpm(token_replace('[node:metatag:title]', array('node' => $node)));

And you'll get the following: Error: Call to undefined function token_get_entity_mapping() in metatag_token_generate_array() (line 143 of /Users/XXX/Sites/localhost/XXX/modules/metatag/metatag.tokens.inc).

This happens with ANY token of type metatag.

Token replacements for metatag token types don't work at all. I realize that the metatag token type is probably not very common (it's not used to place the meta tags in the head section of the page). However, there are some legitimate use cases, for example, outputting the value of specific tags for informational purposes.

The problem here is that there is no replacement for function token_get_entity_mapping() in Backdrop.

argiepiano commented 1 year ago

PR provided #113

Rather than porting that missing function, a couple of lines of code can take care of this. The missing function basically looked up the token name for a given entity type (e.g. "term" for "taxonomy_term"). That can be done with entity_get_info and a conditional assignment.

quicksketch commented 1 year ago

Super, thanks @argiepiano! I merged https://github.com/backdrop-contrib/metatag/pull/113 into 1.x-1.x.