Use the Flag to mark the essence Comments (change)

flag tag module is a flexible module, this module can be marked using any node, comment, user, etc, can this module will be marked as the essence of the node, the garbage or you want to be labeled. flag modules can be views2 integrated to operate, while flag also support action. the official site has a very detailed document.

Now I will talk about the use of Flag module, to add a comment on the essence.

Flag module installation

And, like all modules, download, install the module settings.

Flag module configuration

Global's flag and private flag, the flag module is divided into global and private labeled Category 2, if the private flag, so each has only to tag the person can go to change it without affecting others, such as of the article for collection, the overall situation after the flag change will affect all users, such as the administrator of the comment to add precision, then everyone will see the essence of signs.

With the admin / build / flags carried on the flag set:

Increase after being at the front desk can comment on the essence of symbol nodes.

Block into the template to specify the location, you can see the essence of comments.

Flag module used in the template.

In front of them complete, of course, not end, how to join the comments and general comments essence no different, it should be some settings for the template. Reference content here

Open the template file in the template.php file, adding phptemplate_preprocess_comment function

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);

Whether this is a sign to obtain the essence, and if so, adding a $ vars ['flag_classes'] class. This stuff can be used in comment.tpl.php file.

<! - Start comment.tpl.php ->
<Div "comment <? Php print $ comment_classes;?> Clear-block">
<? Php print $ picture?>
<? Php if ($ comment-> new):?>
<a> </ a>
<span> <? php print $ new?> </ span>
<? Php endif;?>
<H3 "title <? Php echo $ flag_classes; ?>"><? php print $ title?> </ H3>
<div>
<? Php print $ submitted?>
</ Div>
<div>
<? Php print $ content?>
<? Php if ($ signature):?>
<div>
<? Php print $ signature?>
</ Div>
<? Php endif;?>
</ Div>
<? Php if ($ links):?>
<div>
<? Php print $ links?>
</ Div>
<? Php endif;?>
</ Div>
<! - / End comment.tpl.php ->

I joined the red part of the code, if it is the essence of the case, then the title will have a CSS class called comment-flagged-picks, which picks me flag name.

Then in your template CSS file to add

. Comment-flagged-picks (
background: url ('images / raquo.png') no-repeat left 0.833em; / / picture of course, find their own
padding-left: 13px;
)

Special attention Flag module also supports templates, but the template file is used flag - flagname.tpl.php, is 2 -, A moment's inattention, out for a long.

分类:PHP 时间:2010-09-09 人气:192
分享到:
blog comments powered by Disqus

相关文章

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.106 (s). 15 q(s)