用户登录

Drupal资源链接

http://zhupou.cn
drupal布道者,改成了"老葛的Drupal培训班",专心于培训事业
http://drupal.org
官方网站
http://drupalchina.org
中文的官方网站
http://acquia.com/
本站就是用这个版本构建的

在flag模块中用图片替代链接的处理

flag模块默认为使用的是文本链接,如何使用图片来替代文本链接,这里给出了一个解决方法

在模板的中加入预处理函数,就是在模板文件的template.php文件中,加入下列代码

function phptemplate_preprocess_flag(&$vars) {
$image_file = path_to_theme() . '/flag-' . $vars['flag_name_css'] . '-' . ($vars['action'] == 'flag' ? 'off' : 'on') . '.png';
// Uncomment the following line when debugging.
//drupal_set_message("Flag is looking for '$image_file'...");
if (file_exists($image_file)) {
$vars['link_text'] = '<img src="' . base_path() . $image_file . '" />';
}
}

 

注意事项

  • 将flag组件下的theme目录中的flag.tpl.php要复制到模板目录中
  • 要加入图片文件(flag-flagname-on.png,flag-flagname-off.png,)
  • 清空缓存之后,再看效果