Special comment theming

maulwuff - March 15, 2008 - 16:49
Project:Advanced Forum
Version:6.x-1.x-dev
Component:Styles
Category:task
Priority:normal
Assigned:Michelle
Status:closed
Description

I noticed the following:
Browsing the forum as user #1 does not differentiate between published and unpublished comments. I unpublished a comment, and nothing happened - was confusing.

So I came up with this: Color the left part of a comment in another color to make unpublished comments noticable.

In the module file modify:

<?php
function advanced_forum_preprocess_comment(&$vars) {
  if (
_is_forum('comment',$vars)) {
   
// Use our combined node/comment template file
    // D5 won't find templates in subdirectories so we need to give it that
   
$forum_theme = advanced_forum_get_forum_theme_directory();
   
$vars['template_files'][] = "$forum_theme/advf-forum-post";
#mod start
   
$vars['unpub'] = $vars['comment']->status;
#mod end
 
.......
?>

in advanced_forum.css add

.forum-post-wrapper-unpub {
background: #808080 url(images/forum-separaterRed.jpg) repeat-y;
border-top: thin solid darkgray;
border-bottom: thin solid darkgray;
}

Next, save the attached image to your themes/xyz/advforum/images directory, or use your own file. I called it forum-separaterRed.jpg

Last, edit advf-forum-post.tpl.php and add at about line 62:
leading:

  <div class="clear"></div>

insert:
<?php if ($unpub) : ?>
  <div class="forum-post-wrapper-unpub">
<?php else : ?>
  <div class="forum-post-wrapper">
<?php endif; ?>

following:
    <div class="forum-comment-left">

AttachmentSize
forum-separaterRed.jpg362 bytes

#1

Michelle - March 17, 2008 - 21:26
Status:active» postponed (maintainer needs more info)

Hmm.. I'm on the fence on this one. Theming unpublished nodes/comments differently seems like it should be part of the over all site theme . But I suppose it wouldn't really hurt to add it. Any other opinions on this?

Michelle

#2

JConnell - March 17, 2008 - 23:49

This would be a fantastic addition IMO. Like the OP, I often get confused which posts are published/unpublished while administering forums.

#3

Michelle - March 18, 2008 - 00:47
Title:Look for unpublished comments and make them noticable» Special comment theming
Category:feature request» task
Assigned to:Anonymous» Michelle
Status:postponed (maintainer needs more info)» active

Ok, what the heck, I'll put it in. People can always take it out of their themes if it clashes with what their main theme has set.

While I'm at it, I'll add in a class for own comments, though I don't think I'll add any default CSS for that...

I also had someone ask once for a little something extra on new comments. Might as well do that while I'm at it.

Anything else?

Michelle

#4

JConnell - March 18, 2008 - 17:38

This might be another task/module entirely or too large of a project, but since you're listening... :)

What about a class for replies from the Author/OP?

Sony's official playstation blog implemented this not too long ago with fantastic results (see attached). They recently released their work as a wordpress plugin.

Again, I really have no idea how hard this would be to implement but I figured I may as well suggest it.

Thanks as always Michelle!

AttachmentSize
author_comments.png 57.31 KB

#5

Michelle - March 18, 2008 - 18:12

Sure, I can do that, too.

I was going to work on this today but the advanced profile queue is getting really bad. I'm going to take a short break from forums and give that a bit of love. Should be able to get to this issue within the next day or two because it's an easy addition. I know just how to do it... Just need to take a bit of time and add it in.

Michelle

#6

maulwuff - June 24, 2008 - 18:45
Version:5.x-1.0-alpha3» 5.x-1.0-alpha10

applies still to aplha10

#7

Michelle - June 24, 2008 - 18:51

Thanks but there's no need to update version on old issues. Whenever I have time to work on this I look at all the open issues, regardless of versions, to see what I can tackle.

Michelle

#8

maulwuff - June 24, 2008 - 19:09

ok, just had to redo this procedure because I updated to alpha10! :P

#9

Michelle - August 20, 2008 - 04:28
Status:active» duplicate

Consolodating into #268684: Retheming - one way forward.

Michelle

#10

Michelle - October 24, 2008 - 23:14
Version:5.x-1.0-alpha10» 6.x-1.x-dev
Component:Theming» Styles
Status:duplicate» active

Unconsolodating since it got missed.

Michelle

#11

maulwuff - November 2, 2008 - 09:41

some help for you, based on D5 alpha12.

sorry for not providing a patch, I've got too much changed in the module.
it is a 3-step change:

1. in function advanced_forum_preprocess_comment
add this:

$variables['unpub'] = $variables['comment']->status;

2. in advf-forum-post.tpl.php
at about line 63 add this:

leading code:

    <?php if (!$top_post): ?>
      <span class="post-num"><?php print $comment_link . ' ' . $page_link; ?></span>
    <?php endif; ?>
  </div>

insert:

<?php if ($unpub) : ?>
  <div class="forum-post-wrapper-unpublished">
<?php else : ?>
  <div class="forum-post-wrapper">
<?php endif; ?>

3. in advanced-forum.css
at around line 57 add this: (the line number may be completely wrong)

leading:

/*** FORUM THREADS ***********************************************************/

.forum-post-wrapper {
    background: #F7F5EE;
   
}

insert:
.forum-post-wrapper-unpublished {
  background: #FFC8BB;
}

adjust the color to your need.

hope this saves you some time.

#12

Michelle - November 2, 2008 - 14:25

Thanks for the effort but that isn't how I'm planning on doing it. I'll get to this as soon as we get the layout problems fixed. No sense in me adding to the CSS when it's in flux.

Michelle

#13

Michelle - November 3, 2008 - 20:07

I've given this issue a lot of thought and I keep coming back to my original feeling that this CSS is the theme's responsibility, not AF's. However, AF needs some way of knowing what the theme wants. I took a look at some of the major themes as well as #306358: Add $classes to templates with new theme_process_hook functions and it looks like the goal is to use the variable $classes to hold these special classes. Some themes are still using $node_classes and $comment_classes as well. So I ended up merging these into $classes to cover both possibilities and adding it to advf-forum-post.tpl.php. At the moment, it's only on the naked style and only in D6 as I'm adding it in along with other work being done on the forum topics. I'll leave this active until it's on all styles in both branches but wanted to give an update with "the plan".

Michelle

#14

Michelle - November 9, 2008 - 05:32
Status:active» fixed

This is now in all the styles in D6 and will end up in D5 when I copy the styles over after some other stuff gets fixed.

Michelle

#15

System Message - November 23, 2008 - 05:41
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#16

aharown07 - March 11, 2009 - 02:29
Component:Styles» Code
Status:closed» active

Did this get taken out again? I'm using latest (I think) 6.x-1.x-dev and noticed my unpublished comments look the same as published ones... using firebug to look at classes and stuff it doesn't look like it's got anything for 'unpublished'... so I'm not sure if I'm missing something, but I can't seem to find a class to style.

#17

Michelle - March 11, 2009 - 03:42
Component:Code» Styles
Status:active» fixed

Nope, it's still there. Maybe the theme you're using isn't doing anything special with unpublished comments.

Michelle

#18

aharown07 - March 12, 2009 - 21:21

I guess that's possible but I don't see a class showing up for unpublished comments as distinct from published ones. If I did, I'd just write some CSS. But they do not appear to be distinguished at all so I'm guessing something is maybe interfering? The class for unpub gets applied in preprocess somewhere?
I'm just trying to figure out why the source doesn't look any different... no hint of unpub status at all.

I don't know if these means anything but, oddly, if I put a <?php if ($comment->status == comment-unpublished) print ' comment-unpublished'; ?> in various places in advf-forum-post.tpl.php, all the corresponding published comment divs get "comment-unpublished" added to their classes (and they turn colors accordingly), but the unpublished ones don't. But if I change the operator to doesn't equal... != comment-unpublished, the unpublished ones get the "comment-unpublished" class.

So, in short, I can make unpublished posts look unpublished now, but how it's working doesn't make any sense to me unless something is incorrectly reversing the status of the comments & posts somewhere.

#19

Michelle - March 12, 2009 - 21:26

"The class for unpub gets applied in preprocess somewhere?"

Ah, that's where the misunderstanding lies. No, that would get applied in your theme. All AF does is print the two most common variables that themes use to add this sort of class. It doesn't create the variables itself. If you don't have a theme that creates variables for unpublished comments then you won't see anything in AF, either.

Michelle

#20

aharown07 - March 13, 2009 - 00:42

OK. Got it. Will just build it in there somewhere. Tks.

Edit: actually, I'm completely confused. Isn't the only variable involved for this $status which is set in the core? My theme has a comment.tpl.php that assigns a class based on the status variable...but it only seems to "work" when I have AF turned off. Anyway, I've got a topic open in the theming forum so somebody there will probably straighten me out.

#21

Michelle - March 13, 2009 - 01:07

#22

aharown07 - March 13, 2009 - 02:01

Way over my head I'm afraid. I think I'm just going to do what I did in #18 and hope it keeps working, though I don't really get why it works at all.

#23

Michelle - March 13, 2009 - 02:10

Sorry, I didn't look that closely at your code before. I know why it's working. You have:

<?php
if ($comment->status == comment-unpublished) print ' comment-unpublished';
?>

Since "comment-unpublished" isn't defined as anything, it's essentially 0. So you're saying if status is 0, print ' comment-unpublished'. For some reason Drupal has things backwards and puts the status the reverse of what you'd expect. I believe this got fixed in D7.

Michelle

#24

Michelle - March 13, 2009 - 02:11

Here's the issue about status 0 being published: http://drupal.org/node/237636

Michelle

#25

aharown07 - March 13, 2009 - 16:59

Ah.... emerging slowly from fog. Tks.

#26

System Message - March 27, 2009 - 17:00
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.