Drupal 7在wysiwyg中添加快捷码

Drupal 7在wysiwyg中添加快捷码,drupal,drupal-7,Drupal,Drupal 7,我需要一个可能性,以增加本年度的某处在网站上所见即所得。 类似于“现在是[年]年”。 我可以为它创建模块,但它很复杂。有更好的主意吗? 我已经安装了ckEditor 您可以使用 安装此模块时,您可以在此日期之前插入年份:[Y] 注意。您可以使用它,并对其进行扩展以创建自己的自定义短代码,并在ckeditor中使用它 自定义短代码创建参考链接: 例如,查看以下3个函数以创建按钮短代码: /** * Define our process callback function for our [bu

我需要一个可能性,以增加本年度的某处在网站上所见即所得。 类似于“现在是[年]年”。 我可以为它创建模块,但它很复杂。有更好的主意吗? 我已经安装了ckEditor

您可以使用

安装此模块时,您可以在此日期之前插入年份:[Y]

注意。

您可以使用它,并对其进行扩展以创建自己的自定义短代码,并在ckeditor中使用它

自定义短代码创建参考链接:

例如,查看以下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);
}
/**
*为[button]短代码定义进程回调函数。这
*从短代码中获取我们的短代码属性,如果为空,则设置属性
*设置为此函数中指定的默认值。然后,我们将属性传递给
*输出HTML的主题()函数。
*
*$attrs=shortcode\u attrs(数组(
*'属性'=>'默认值在此处'
* ),
*/
函数自定义\u短代码\u短代码\u按钮($attrs,$text){
$attrs=shortcode\u attrs(数组(
'链接'=>'http://mywebsite.com'
),
$attrs
);
返回主题('shortcode_按钮',数组('link'=>$attrs['link'],'text'=>$text));
}
/**
*此函数使用传入的属性返回此短代码的HTML。
*/
函数主题\短代码\按钮($vars){
返回“”;
}
/**
*此函数在所见即所得编辑器下向用户输出一些提示,以便他们知道
*短代码的作用和使用方法。
*/
函数自定义\u短代码\u短代码\u按钮\u提示($format,$long){
$output=array();
$output[]=''.t('[按钮链接='http://URLhere.com“]text[/button]”)。;
如果(长){
$output[]=t('输出显示为按钮的文本,链接到指定的URL')。

'; } 否则{ $output[]=t('输出链接到URL的文本')。

'; } 返回内爆(“”,$output); }