Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Alter first comment?

edited February 2007 in Vanilla 1.0 Help
Is there a method to change the look of the first comment in a discussion? I mean the post of the one who started the discussion.


  • If you check the RowNumber delegate parameter, it will tell you if you are looking at the first comment or not:
    $Context->SetDefinition('AfterFirstPostCode', '<hr style="border: 0 1 #ccc" />Insert code here'); $Context->SetDefinition('AfterLastPostCode', '<hr style="border: 0 1 #ccc" />Insert code here'); function TweenPost(&$CommentGrid) { // Insert the ad code after the last </li> $CommentList = &$CommentGrid->DelegateParameters['CommentList']; $RowNumber = &$CommentGrid->DelegateParameters['RowNumber']; $Comment = &$CommentGrid->DelegateParameters['Comment']; if ( 1 == $RowNumber ) { $Comment->Body .= $CommentGrid->Context->GetDefinition('AfterFirstPostCode'); } else { if ( ($CommentGrid->CommentDataCount == $RowNumber) || ($CommentGrid->Context->Configuration['COMMENTS_PER_PAGE'] == $RowNumber) ) { $Comment->Body .= $CommentGrid->Context->GetDefinition('AfterLastPostCode'); } } } $Context->AddToDelegate('CommentGrid', 'PreCommentOptionsRender', 'TweenPost');
  • Thanks for this code! Where to put it into? I tried some ways but always get an error.
  • Tex, Just make a new extension.. or Wallphone can create his own considering how helpful it is.
  • Ah, as an extension. I'll try this. Thanks!
  • Wasn't there a CSS tag like Comment_First or something? Was it done away with?
  • TexTex
    edited January 2007
    @ Krak:
    I couldn't find any. Neither in the css file nor at the source code of the page.
  • All right. This enables me to add anything I want after the text of the first comment. Has anybody an idea how to alter the look of it? I could imagine opening a div before it and close it after the comment. But how to add something before the first comment? Sorry, I am not good in this as you see.
  • I could have swore there was something like Comment_First, but I looked and couldn't find it either. It must have been removed or I am blind/looking in the wrong spot.

    I swear I have used it before.
  • One thing you could do: $Comment->Body = '<div class="FirstComment">'. $Comment->Body .'</div>'; But that would only single out the body of the first comment... Maybe look at the beautiful lie theme if you are trying to get a blog-like appearance.

    There was a FirstComment class in .9.2.6 Not sure why it didin't make it into later versions. (Maybe because you can get the same effect with a :first-child CSS selector?)#Comments li:First-Child { border: 2px solid #f00; }But this seems to do things to the comment author and icon fields... and I am not familiar with how well browsers use it.
  • @ WallPhone:
    The first method is very well for the beginning, thanks!
    The 'First-Child' is not supported by IE.
    The Beautiful Lie theme doesn't alter the look of the first comment, as far as I can see.
  • What about the Adjacent-Sibling Selectr? That should work with IE?
  • did any body ever make any progress on this?
  • TexTex
    edited February 2007
    The method proposed by WallPhone works fine:
    $Comment->Body = '<div class="FirstComment">'. $Comment->Body .'</div>';
    Than you can define the class in you CSS stylesheet.
This discussion has been closed.