You are here

flag 模块在模板中的应用

dghabc 的头像
Submitted by dghabc on 星期三, 2009-04-15 02:37

测试一下,看看怎么样 打开模板文件中的template.php文件,加入phptemplate_preprocess_comment函数 static $flags; if (!module_exists('flag')) { return; } if (!isset($flags)) { $flags = flag_get_flags('comment'); } // Note: is_flagged() and get_count() use internal cache, // so using them won't result in issuing excessive SQL queries. $classes = array(); $cid = $vars['comment']->cid; foreach ($flags as $flag) { $css_name = str_replace('_', '-', $flag->name); if ( $flag->is_flagged($cid)) { $classes[] = 'comment-flagged-' . $css_name; } } $vars['flag_classes'] = implode(' ', $classes); 这段是取得是否标志精华,如果是的话,加了一个$vars['flag_classes']的类。这个东东就可以在comment.tpl.php文件中使用。

clear-block"> <?php print $picture ?> <?php if ($comment->new): ?> <?php print $new ?> <?php endif; ?>

"><?php print $title ?>

<?php print $submitted ?>

<?php print $content ?> <?php if ($signature): ?>

<?php print $signature ?>
<?php endif; ?>
<?php if ($links): ?>

<?php print $links ?>
<?php endif; ?>

红色部份是我加入的代码,如果是精华的话,那么会在标题中有一个CSS类叫comment-flagged-picks,其中picks是我flag name. 然后在你的模板CSS文件中加入 .comment-flagged-picks{ background: url('images/raquo.png') no-repeat left 0.833em; //图片当然自己去找 padding-left: 13px; } 详细内容:http://joom.net.ru/content/shi-yong-flaglai-biao-ji-jing-hua-ping-lun

论坛:

Drupal版本: