Created
July 16, 2013 17:35
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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