- π¦πΊAustralia VladimirAus Brisbane, Australia
Drupal 7 is end of life β and no longer supported.
Closing the issue as outdated.
Not sure what is going wrong here but I am sure it is simple.
The token [node:field_report_store_name]
("Text field" token) doesn't handle special characters which [node:field-report-store-name]
("Field 'field_report_store_name' token) takes care of. This token, however, works alone without PHP, but when I try to use it in a PHP pattern, I get an Unexpected Error upon updating the automatic node title.
The below works without error, but special characters such as apostrophes display as "'
":
$storename = '[node:field_report_store_name]';
$city = '[node:field-report-zip:locality]';
$state = '[node:field-report-zip:administrative-area]';
if(empty($storename)) {
return $city.", ".$state;
} else {
return $storename." in ".$city.", ".$state;
}
The below is the exact same code but with the token that handles the special characters, and produces an Unexpected Error:
$storename = '[node:field-report-store-name]';
$city = '[node:field-report-zip:locality]';
$state = '[node:field-report-zip:administrative-area]';
if(empty($storename)) {
return $city.", ".$state;
} else {
return $storename." in ".$city.", ".$state;
}
The settings are set correctly:
The error as reported in the dblog says:
ParseError: syntax error, unexpected 's' (T_STRING) in auto_entitylabel_eval() (line 2 of /sites/all/modules/auto_entitylabel/auto_entitylabel.module(447) : eval()'d code).
This would be the following function:
/**
* Evaluates php code and passes $entity and $language to it.
*/
function auto_entitylabel_eval($code, $entity, $language = LANGUAGE_NONE) {
ob_start();
// @codingStandardsIgnoreLine
print eval('?>' . $code);
$output = ob_get_contents();
ob_end_clean();
return $output;
}
The problem must come from the fact that my apostrophe ('
) is an escaped quote ', that is intended to prevent breaking a string when the module evaluates the code.
For example, if the token evaluates to that's a single quote, then some portion of the code may evaluate to
$token = 'that's a single quote';
which will break on the 's', hence the unexpected 's' (T_STRING)
Is this a module bug or how do I overcome this in the PHP pattern?
Closed: outdated
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Drupal 7 is
end of life β
and no longer supported.
Closing the issue as outdated.