
You want the comment style to be different for comments added by the author of a node — who's commenting on his own node. For example, you may want to highlight the node's author's comments, so that any visitor skimming through the comments will easily differentiate them from other comments.
Edit comment.tpl.php to add a new class (let's say 'comment-by-author-of-post') that...
you can style in your theme's style.css.
Your file comment.tpl.php may look like this before the edit (I am only providing a snippet of the template here):
<div class="comment<?php print ($comment->new) ? ' comment-new' : ''; print ' '. $status ?> clear-block">If it does, then you will change the above snippet to that:
<div class="comment<?php print ($comment->new) ? ' comment-new' : ''; print ($comment->uid == $node->uid) ? ' comment-by-author-of-post' : ''; print ' '. $status ?> clear-block">You could now add these two rules to your style.css file, for example:
/** * Comment styling rules */ .comment-by-author-of-post { border: 1px solid #ccc; background-color: #eee; } /* reset to default values when previewing */ .preview .comment-by-author-of-post { border: none; background-color: transparent; }
This will work in Drupal 5 as well. No, it won't. The $node object is not passed to the comment.tpl.php template. Read the comments below for the Drupal 5 recipe. This solution works only for PHPTemplate-powered themes. If your theme does not provide a template file for comments, copy the one from modules/comment/ to your theme folder, and edit it. And yes, the $node object is available in comment.tpl.php. It is the node the comment is attached to. Possible variations: special-style all comments authored by those who have the 'admin' role; special-style anonymously-submitted comments; etc.
Comments
Drupal 5?
I am sorry, but this one seems not working with Drupal 5? The snippets from the template for Drupal 5 is supposed to be this one:
In Drupal 5, no $node object in comment.tpl.php
What you do have is the nid of the node the comment is attached to.
So what you need to do is pass the node's author uid, along to comment.tpl.php.
Something like this needs to be done in the file template.php of your theme:
Then you can use $node_uid in comment.tpl.php — that'll be the uid of the node author.
<div class="comment<?php if ($comment->status == COMMENT_NOT_PUBLISHED) print ' comment-unpublished'; print ($comment->new) ? ' comment-new' : ''; print ($comment->uid == $node_uid) ? ' comment-by-author-of-post' : ''; print ' '. $status; ?>">Just one author?
Just one blogger on your web site? Do not bother with checking who is the author of the node. Do not bother with passing an additional variable to your comment template.
In the case where you have only one blogger... you could do as I do here (and yes, my web site still runs on Drupal 5...). Using a hard-coded value for the author of the node, eg: 1 (the Administrator of the site):
<div class="comment<?php print ($comment->uid == 1) ? ' comment-by-author-of-post' : ''; print ($comment->new) ? ' comment-new' : ''; print ($comment->status == COMMENT_NOT_PUBLISHED) ? ' comment-unpublished' : ''; print ' '. $zebra; ?>">Thanks
Sorry for my noobness, but thanks! It works wonderfully on my site. Thanks, once again.
It was my mistake
It was my mistake.
I corrected my 'tutorial', and I am now saying:
Thanks to you!
Thanks for the confirmation
Thanks for the confirmation - had to come back to tell you it didn't work... but of course now it does!
The author's theme's choice
The author's theme's choice was really awesome and now I do understand why she has to choose this. Dental Saratoga Springs
woaw, thanks for the code
woaw, thanks for the code.
Thanks for the code, it
Thanks for the code, it really works great, just tried it. pmp certification prep
great
Oh well, I am not sure that this is going to be so well.. I do also agree with you too. real estate careers nyc
Hi
Hi there! I simply would like to give you a big thumbs up for the excellent information you've got here on this post. Cheers. ebrandz reviews
Hello
I like your post. It's very useful. . I am returning to your web site soon. ebrandz reviews
Hi
Your website is very useful. Thanks for sharing. Looking forward to read more! leadfire
This is a wonderful article,
This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck. ebrandz reviews
Many many thanks for giving
Many many thanks for giving the required format.
following link is useful
www.jgsupplements.com
Want to know more
I have a little bit knowledge about drupal 5.So I have faced so many problem like you.I want to get more information about it.Help me please..:)
I have added the code, and
I have added the code, and its working great. thanks for sharing for this important code or script. how do you recycle electronics
I have already copied and
I have already copied and pasted it on my consul, and its really working great, thanks for the share, I will definitely share this article to my friends out there. Accountant Website Design
Thanks for the good info.
Thanks for the good info. services I saw this happening on some websites, but didn't know how to implement it
great
I don't just actually understand what's this means "theming comments by the node's author"? perky jerky
The Drupal core installation
The Drupal core installation can be used as a brochureware website, a single- or multi-user blog, an Internet forum, or a community website providing for user-generated content. American Leather comfort sleeper sale
Ah. Thanks for the good
Ah. Thanks for the good info. I saw this happening on some websites, but didn't know how to implement it. Thanks Caroline!
Drupal 5
Thanks for the comments on Drupal 5. I was having trouble. Now I know why.
Good Info
Good Info, thanks
Nice write up
Nice write up
Which Drupal version does this work for?
Hi guys,
Just reading the comments, what version of Drupal does the above example work for? I read issues with Drupal 5 so does this mean its a Drupal 6 solution? Or is it Druapl 4?
I'm looking for the Drupal 6 solution.
Cheers,
Gavin.
PS: What WSYIWIG are you using with Drupal?
Hi Gavin
Drupal 6.
None. I use BUEditor. It's not WSYIWIG per say, although it's an editor and has a really nice ajaxified preview button. I loooove it: http://drupal.org/project/bueditor.
Ah, finally. I was wondering
Ah, finally. I was wondering why I was having trouble.
Off to implement this code...
awesome
This is such a great idea, but I have not seen many sites using it. I wonder why. It would really help me, so I am glad to see you have created this theme. Thanks so much for the instructions.
this works
This works rally well, and I think it is crucial to the comments on a blog to be able to distinguish this. thanks
I would agree that this is
I would agree that this is an awesome fix to a problem I've been having for almost a month! Thank you for the insight.. Going to change it right now.
Thank you so much for the
Thank you so much for the information
Thanks
Thanks! Good info!
good tutorial
admin,
I think I will update my site following your tutorial.
Hope it is easy like you explained it because I'm a beginner.
Page bookmarked.
it works
thanx for your information
it works
nice article
Great information
As a noob and has no knowledge in php programming, this infomation can greatly teach me on how to do hard things easy.
Theme coding for authors/admins
Edited the comment.tpl.php and added the two rules to the css file and it worked like a charm. Thanks Caroline, for providing the code, I was spending a lot of time searching Google and couldn't find anything on how to change the admin highlighting style to distinguish them from regular users until I found this post.
- Brian
I looked all over google for
I looked all over google for it!! Thanks for the info..pfff! :)
What about the CAPTCHA
How did you create this unique CAPTCHA? Are you using any commercial extension?
comments.tpl.php
Had some problems with the php file at the beginning, but i think i got it nwo right. Thank you.
-Antti
Here some info about
Here some info about $attributes, $title_atributes, and $content_attributes:
http://drupal.org/node/254940#html-attributes-variable
Imobiliária Salvador
comment style
That comment style tip is very helpful, thank you!
Thanks. Although I'm not a
Thanks. Although I'm not a big fan of Drupal (i'm a .net developer) I have a new client that wants a website developed with drupal and I'm still trying to learn it :)
I was stuck in the middle
I was stuck in the middle while trying it in my Joomla 1.5 site. The border is solid here but by default I have a nice border from the template maker though the solid code didn't worked as I applied that. Oh Can you write something about Google + button code and where to put is in which page. It looks like people are talking about footer.php but I need a confirmation from you.
Drupal is very powerful, but
Drupal is very powerful, but it has some modules that are very slow. I think the coding style used to develop them is saying it's word here. php isn't that slow, it should be faster than asp.net
Excellent post and wonderful
Excellent post and wonderful blog, I really like this type of interesting articles keep it u. I am really loving the theme/design of your web site. editing service
I am making a code with the
I am making a code with the new extension. Here is the real node and fixer for all updates. Using a drupal code without the planning and without using the extension is so tough. I don't think only this code will not work for me if you make a video and upload it in the page or make a youtube link.
thanks for the tips. I think
thanks for the tips. I think this will also work in wordpress and joomla, right? because it's still PHP property mallorca
Thanks for the good info. I
Thanks for the good info. I saw this happening on some websites, but didn't know how to implement it
Good idea and detailed instructions!
It would be prudent to synchronize and back-up all your hard work with a service that provides online backup.
Thank you.
I was stuck in the middle
I was stuck in the middle while trying it in my Joomla 1.5 site. The border is solid here but by default I have a nice border from the template maker though the solid code didn't worked as I applied that.
The combined water/amusement
The combined water/amusement park retreat on the periphery of Naples, Italy, offers great. the act of removing floating material from the surface of a liquid. I like to visit this post once again thanks for sharing the informative post.
Regards,
Robert - www.paperwisdom.co.uk
DreamBoard theming tweak
DreamBoard theming tweak goes free for iPhone and iPod touch. Dreamboard is a fantastic Cydia jailbreak Tweak for the folks. Tweak My Theme is currently being re-structured to create a much more seamless process for getting your WordPress theme tweaked. We'll be matching you up with a pool of talented WordPress developers, allowing you to get your site customized to your exact specs...and quickly. Thanks for sharing.
Regards,
Robert - Kitchen Design Bath
There should be no crying
There should be no crying allowed at Magic World. The place is too much fun. The combined water/amusement park retreat on the periphery of Naples, I like to visit blog ones again thanks for sharing the informative post.
Regards,
Robert - Access Intelligence Media and Communications Ltd
Skim links uses Google
Skim links uses Google Analytics, a web analytics service provided by Google, Inc. Google Analytics sets a cookie in order to evaluate your use of the website. I like to discuss more about this thanks for sharing the informative post.
Regards,
Robert - ENT doctor surrey uk
kamagrea rezeptfrei kaufen
It is just what I was looking for and quite thorough as well. Thanks for posting this, I saw a couple other similar posts but yours was the best so far. The ideas are strongly pointed out and clearly emphasized. Thanks for sharing your thoughts and ideas on this one. Please keep posting about such articles as they really spread useful information. Thanks for this particular sharing. I hope it stays updated, take care.
Description and explanation
Description and explanation of the major themes of The Power of One. Adaptivetheme is a powerful theme framework designed from the ground up to power modern, cross browser/cross device. Thanks for sharing the informative post.
Regards,
Robert - Salmon Recipes UK
Social Networking to Get You
Social Networking to Get You the Best Deals The economy is so unstable at the moment that most of us are continually looking for methods to cut financial corners, even if it only adds up to a couple of cents.
Medical Billing and Coding
Theme Tweaks is Philippines
Theme Tweaks is Philippines based firm committed to help businesses get online! We create websites using dynamically designed templates which you owner can easily. I like to discuss more about this thanks for sharing the informative post.
Regards,
Robert - Zeno
Skimlinks uses Google
Skimlinks uses Google Analytics, a web analytics service provided by Google, Inc. Google Analytics sets a cookie in order to evaluate your use of the website. thanks for sharing the informative post.
Regards,
Robert - property management Yonkers ny
Theme Tweaks is Philippines
Theme Tweaks is Philippines based firm committed to help businesses get online. we can create websites using dynamically designed templates. Theme customizes WordPress themes to your exact specifications, whether small tweaks or major updates. Thanks for sharing.
Regards,
Robert - new york disability attorney
Brisbane web designer
Thanks for the tips. I think this will also work in wordpress and joomla, right? because it's still PHP.
Brisbane web designer
nice post.
Will try to use this today and see how it goes..
To write an interesting and
To write an interesting and highlight comment was a very difficult problem. And I'm trying to do that.
karting
This became truly very
This became truly very helpful site. I truly enjoyed what sort of written content had been published. I will be content to help save this web site in to our folder. Many thanks! The way you express yourself is awesome.
Regards,
Sam - Janine Edwards St James’s Place
That was new blog i never
That was new blog i never thought of that. Many interesting blog that you brought to us is about the a centering point of component parts of the author which bring me for applying it i needed. So for now i say it is good and all i wanted to know from your blog the answer of my question.
Nikeskono Norge online
billige nike sko i norge ved nikeskono.eu,tilbyr merke sko til konkurransedyktige priser,nike free 3.0 Sko Salg i norge,converse sko norge av nye mainstream i Norge selges Norge maksimal converse sko store online billig salg! Hoy kvalitet og 100% tillit lofte.
The way you express yourself
The way you express yourself is awesome. superuser apk
amazing!
this is a great thing to know "You want the comment style to be different for comments added by the author of a node — who's commenting on his own node. For example, you may want to highlight the node's author's comments, so that any visitor skimming through the comments will easily differentiate them from other comments"..more power http://www.nuediamonds.com/man_made
Custom Directory We are a
Custom Directory
We are a bunch of volunteers and starting a brand new scheme in our community. Your web site provided us with valuable information to paintings on. You have done an impressive job and our entire community will be grateful to you.
Blog
Great technology is visible in this Online Poker Sport blog and the nice services in this blog. I am really like it very much for the nice services in this blog and the good info is visible in this blog.
Post new comment