Skip to content

Instantly share code, notes, and snippets.

@vidhav
Created May 21, 2015 07:12
Show Gist options
  • Save vidhav/86278ebe2b2c3cf3ae56 to your computer and use it in GitHub Desktop.
Save vidhav/86278ebe2b2c3cf3ae56 to your computer and use it in GitHub Desktop.
MODX Output Modifier checks if $input contains a string defined in the $options value.
<?php
/**
* Returns a value if input contains string
* [[*link_attributes:containing=`blank=New Window&self=This window`]]
*/
parse_str($options, $cases);
$output = 'no-match';
foreach ($cases as $needle => $value) {
if (strpos($input, $needle) !== false) {
$output = $value;
}
}
return $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment