1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- $plugin = array(
- 'title' => t("Node: ID"),
- 'keyword' => 'node',
- 'description' => t('Creates a node context from a node ID argument.'),
- 'context' => 'ctools_argument_nid_context',
- 'placeholder form' => array(
- '#type' => 'textfield',
- '#description' => t('Enter the node ID of a node for this argument'),
- ),
- 'no ui' => TRUE,
- );
- function ctools_argument_nid_context($arg = NULL, $conf = NULL, $empty = FALSE) {
-
- if ($empty) {
- return ctools_context_create_empty('node');
- }
-
- if (is_object($arg)) {
- return ctools_context_create('node', $arg);
- }
- if (!is_numeric($arg)) {
- return FALSE;
- }
- $node = node_load($arg);
- if (!$node) {
- return FALSE;
- }
- return ctools_context_create('node', $node);
- }
|