Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save esteinborn/6010848 to your computer and use it in GitHub Desktop.
Save esteinborn/6010848 to your computer and use it in GitHub Desktop.
Check for the actual string of a non-existent node token value in Drupal for auto_node_titles
<?php
$part = '[node:field_episode_part]'; // First we assign the tokenized value to a new PHP variable
$partstring = '[node:' . 'field_episode_part]'; // Sometimes, especially when you are running a mass-update, you need to check for the literal string value, but you need to split it up in order for token to not intercept the value
if((empty($part)) || ($part == $partstring)) { // Next, we check if that new variable is an empty string OR it equals the literal token string value
return; // It is good form to return, even if your code returns no value.
} else {
return " (Part " . $part . ")"; // The formatted string that will be returned.
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment