When adding the pattern for the entity label, there's a "Evaluate PHP in pattern" check box. Below the box, it says, "Put PHP code above that returns your string, but make sure you surround code in and . Note that $entity and $language are available and can be used by your code." I added a snippet like this:
<?php if ($language == 'fr') { // my code } else { // my other code } ?>
But it doesn't seem like $language is actually available. I saw the following error in the DB log:
"Notice: Undefined variable: language in eval() (line 1 of /app/web/modules/contrib/auto_entitylabel/src/AutoEntityLabelManager.php(338) ..."
Please let me know if this is a bug or if I have done something wrong.
Comments
Comment #2
waverate commentedThis worked for me:
Comment #3
colanMy guess is that
$languageis an artifact from D7; it's probably not around anymore. Let's update the help text to talk about the token instead, unless there are better ideas.Comment #4
deaom commentedThis seem to not be a D8 version issue, as I can't seem to find the mentioned checkbox. Currently tokens are available as replacement patterns ([node:langcode] for example), so not sure where the updated text would go.
Comment #5
colan