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.

How could I ad a "class" to the li of the first comment?

edited November 2007 in Vanilla 1.0 Help
Hi, I was wondering how could i ad a class to the div li , for just the first comment of every discussion? wayne


  • It's a theme question I think. Please refer to the docs for a clean theme modification.
    Not tested, but copy themes/comments.php in your new theme folder, you'll find this line
    $CommentList .= '<li id="Comment_'.$Comment->CommentID.'"'.($CommentClass == ''?'':' class="'.$CommentClass.'"').'>
    around line 74. Then just add this line
    if ( $RowNumber == 1 ) $CommentClass .= ' FirstComment';
    BEFORE it.

    Could you please tell us what is this for ?
  • to make the first comment styled differently of course! :P

    I'm gonna try this out
  • edited November 2007
    Yeah, i'm gonna use vanilla as a news platform, and if i can have control over the first comment, then i can make it different from the rest. So the first comment would be the Article, and all the rest can be comments on the article :).. Thanks so much, i'll try it out today :P wayne :)
  • If you want you can skip a little bit of processing time and just do this:

    ol#Comments li:first-child { /* your styles here */ }
  • edited November 2007
    I guess, but i'd like to keep my css all together...
  • that would be great if it worked in all browsers. ie6 still has a big chunk of the market
  • edited November 2007
    Ok, thank you very much... How can i do the same with the discussions??? thanks in advance Wayne :) I'm assuming i'll be editing the Discussion.php file...
  • edited November 2007
    I've been trying the same code for the discussion, but i have no program experience, i speggetti code ;) and can't seem to get results... I do notice that I may want to use $FirstRow = 1; for the discussion one's though, because unlike the comments, these rows sink ;0)
  • I'm not sure this add-on would help, it keeps the discussions in chronological order of posting, newest on top, I love it, it's essential for my needs. Thanks Wallphone

  • That's pretty cool, but want do me any good, i'm just trying to add an extra style class to just the first discussion only :)
  • Yes I think I know what you want, but currently that first discussion moves around as you say.

    With Chronological, it stays on top as long as it's the latest discussion (by creation date not newest comments date).

    By the way, I love your term "spaghetti code" it's much nicer than "hacker" :-)

    Me, I also add meatballs to my spaghetti!
  • Right, but i c there's a variable in the framework $FirstRow instead of $RowNumber so i thought i could just use that... but again, i'm just trying to do the above just like the comments, except with the discussions... I think using $FirstRow should take care of the Chronological problem that would come up. i just can't figure out what to include in the if statement...
  • Ok, i've added a class to the first comments, now how could i use an if statement to get rid of the Author and Date on the first comment?
  • Never mind i c i can use Display:None; for the Comment header in this case :P
  • Do you want this new class on the first page or on every page ?
  • In the first li of themes/discussion.php (maybe line 11), add
    .($FirstRow?' FirstDiscussion':'') to the serie of classes, right before .'">
    Replace $FirstRow by
    ($FirstRow AND ForceIncomingInt("page", 0) < 2)
    if you want only a FirstDiscussion class on the FIRST page of the discussion list.

    (remember hacking themes)
  • Thats it :) thank you so much, I tried doing it myself with no success. Sometimes i get it , sometimes i don't. But i will have to say Vanilla is really helping me to learn php :)
  • Once i finish this theme, i will definitely release it to the vanilla community. It's a News/Mag Theme and the comments part so far, are kinda like articles... where you have the main article and then people can post comments under it. The biggest change is the article looks like an article, doesn't look like a comment at all.
  • A non-existing add-on that would be great for you is TemplateComment.
    Acting when creating a discussion only, this could help the writer of an article (or a bug reporter in our Issue Tracker).
    With a simple javascript onload thing, the comment form could be pre-filled.
    Each category could be assigned a template.
  • edited November 2007
    Your absolutely right! You could have the form laid out with "Title" "Sub-Title" "Article Content" "Conclusion/ Sources..." The reason why I'm using vanilla for the articles in the first place is because search engines especially google Love Vanilla, they eat it up all day :P Here's a link you can copy and paste to check out what I've done so far... Don't want it to be and actual link here yet because don't want google indexing this... I had to get rid of the vanilla links for this theme but will add them to the footer as Powered by Vanilla :) You'll notice my first and only category is label golf blogs, this is perfect also for a blog like system.
This discussion has been closed.