2014-11-06 63 views

回答

0

您可以使用token_insert来做到这一点。

当您安装此模块,您可以通过此插入年份:日期:[Y]

问候。

1

您可以使用https://www.drupal.org/project/shortcode,并扩展它以创建自己的自定义短代码并在ckeditor中使用它。

自定义简码创建参考链接: http://briannadeleasa.com/blog/drupal-php/shortcodes-drupal-yes-you-can

例如,检查出这3个函数来创建我们的按钮简码:

/** 
* Define our process callback function for our [button] shortcode. This 
* takes in our shortcode attributes from the shortcode and if empty, sets the property 
* to the default value stated in this function. We then pass in our attributes to the 
* theme() function which outputs the HTML. 
* 
* $attrs = shortcode_attrs(array(
*  'attribute' => 'default_value_goes_here' 
*), 
*/ 
function custom_shortcodes_shortcode_button($attrs, $text) { 
    $attrs = shortcode_attrs(array(
     'link' => 'http://mywebsite.com' 
    ), 
     $attrs 
    ); 

    return theme('shortcode_button', array('link' => $attrs['link'], 'text' => $text)); 
} 

/** 
* This function uses the attributes passed in to return the HTML of this shortcode. 
*/ 
function theme_shortcode_button($vars) { 
    return '<div class="button"><a href="' . $vars['link'] . '">' . $vars['text'] . '</a></div>'; 
} 

/** 
* This function outputs some tips to the user beneath the WYSIWYG editor so they know 
* what the shortcode does and how to use it. 
*/ 
function custom_shortcodes_shortcode_button_tip($format, $long) { 
    $output = array(); 
    $output[] = '<p><strong>' . t('[button link="http://URLhere.com"]text[/button]') . '</strong> '; 
    if ($long) { 
    $output[] = t('Outputs text that is displayed as a button, which links to a specified URL.') . '</p>'; 
    } 
    else { 
    $output[] = t('Outputs text that links to a URL.') . '</p>'; 
    } 

    return implode(' ', $output); 
}