6 * Plugin to provide an argument handler for a raw string
9 * Plugins are described by creating a $plugin array which will be used
10 * by the system that includes this file.
13 'title' => t("String"),
14 // keyword to use for %substitution
15 'keyword' => 'string',
16 'description' => t('A string is a minimal context that simply holds a string that can be used for some other purpose.'),
17 'settings form' => 'ctools_string_settings_form',
18 'context' => 'ctools_string_context',
19 'placeholder form' => array(
20 '#type' => 'textfield',
21 '#description' => t('Enter a value for this argument'),
23 'path placeholder' => 'ctools_string_path_placeholder', // This is in pagemanager.
27 * Discover if this argument gives us the term we crave.
29 function ctools_string_context($arg = NULL, $conf = NULL, $empty = FALSE) {
30 // If unset it wants a generic, unfilled context.
32 return ctools_context_create_empty('string');
35 $context = ctools_context_create('string', $arg);
36 $context->original_argument = $arg;
42 * Settings form for the argument
44 function ctools_string_settings_form(&$form, &$form_state, $conf) {
45 $form['settings']['use_tail'] = array(
46 '#title' => t('Get all arguments after this one'),
47 '#type' => 'checkbox',
48 '#default_value' => !empty($conf['use_tail']),
49 '#description' => t('If checked, this string will include all arguments. For example, if the path is "path/%" and the user visits "path/foo/bar", if this is not checked the string will be "foo". If it is checked the string will be "foo/bar".'),
55 * Switch the placeholder based upon user settings.
57 function ctools_string_path_placeholder($argument) {
58 if (empty($argument['settings']['use_tail'])) {
62 return '%pm_arg_tail';