Active
Project:
Node Embed
Version:
7.x-1.x-dev
Component:
Documentation
Priority:
Major
Category:
Task
Assigned:
Reporter:
Created:
2 Apr 2012 at 15:25 UTC
Updated:
23 Sep 2014 at 14:27 UTC
Jump to comment: Most recent
Some left over code from another issue we previously closed. I thought you might want to review it and alter it to match your syntax and need to explain the extra embed options:
/**
* Tips callback for hook_filter
*/
function node_embed_filter_node_embed_tips($filter, $format, $long) {
if( !$long ){
return t('[[nid:123]] - Insert a node\'s content');
} else {
$embed_options = _node_embed_options();
$embed_defaults = _node_embed_options_defaults();
$description = '<p>' . t('Node embeds are created from their options automatically.');
$description .= '<br />' . t(
'Wrap your embed in a double set of square brackets "[[ ]]"'
. ' Specify the options for your embed using the pipe character "|" between each option.'
. ' Each option should be a option:value pair, seperated by the colon character ":".'
) . '</p>' . "\n";
$description .= '<ul>' . "\n";
// Nid
$description .= '<li>' . "\n";
$description .= '<p><strong>' . t('nid - required') . '</strong>';
$description .=
'<br />' . '[[<strong>nid:12345</strong>|option:value]]'
. '<br />' . t('The id of the content. This can be found easily by looking at the edit url of a piece of content. "http://www.example.com/node/<strong>{nid}</strong>/edit".')
. '</p>' . "\n";
$description .= '</li>' . "\n";
// Mode
$description .= '<li>' . "\n";
$description .= '<p><strong>' . t('mode') . '</strong>';
$description .=
'<br />' . '[[nid:12345|<strong>mode:full</strong>]]'
. '<br />' . t('Default: %mode', array('%mode' => $embed_defaults['mode']))
. '<br />' . t('Options: %modes', array('%modes' => implode(', ', $embed_options['mode'])))
. '<br />' . t(
'The view mode that should be used to render the content. Additional modes may be added using the <a href="!url">Entity View Mode</a> module.'
,array(
'!url' => url('http://drupal.org/project/entity_view_mode'),
)
);
$description .= '</ul>' . "\n";
return $description;
}
} // node_embed_filter_node_embed_tips
function _node_embed_options(){
static $options = NULL;
if( !empty($options) ){
return $options;
}
$options = array();
// Get the available view modes for nodes
$options['mode'] = array();
$entity_info = entity_get_info('node');
$view_modes = $entity_info['view modes'];
$limited_view_modes = array();
foreach($view_modes as $mode => $values){
// Throw out types that make no sense to embed
if( !in_array($mode, array('rss', 'token', 'search_index')) ){
$options['mode'][] = $mode;
}
}
return $options;
}
function _node_embed_options_defaults(){
return array(
'mode' => variable_get('node_embed_options_default_mode', 'node_embed'),
);
}
Comments
Comment #1
mrharolda commentedComment #2
mrharolda commented