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')) (
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>
<? Php print $ submitted?>
</ Div>
<? Php print $ content?>
<? Php if ($ signature):?>
<? Php print $ signature?>
</ Div>
<? Php endif;?>
</ Div>
<? Php if ($ links):?>
<? 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 人气:199
blog comments powered by Disqus


iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 闽ICP备15018612号

processed in 0.034 (s). 14 q(s)