Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Where do I change the comments HTML?

edited August 2012 in Vanilla 2.0 - 2.8

I'd like to change <span class="Author"> to <span class="Author username">

So I think I need to change it to <span class="Author <?php echo $Author; ?>"> but in which file?

I tried applications/conversations/views/messages/messages.php but that made no difference.

I've looked in the documentation, but as a designer and front-end developer who can copy & paste a bit of php, even the first line is foreign to me: "Once a controller method is called to handle the request..."

Thanks for your help!



  • Options
    ToddTodd Chief Product Officer Vanilla Staff

    You need to know off the bat that changing this html is not recommended as you'll be fiddling with core files and you are breaking your chances of upgrading in the future. What is recommended is you just target the appropriate css classes that are already present in the html.

    That being said, you can find anything display related in the various views folders. The ones you are looking for would be I think:

    • /applications/vanilla/views/discussion/discussion.php
    • /applications/vanilla/views/discussion/helper_functions.php

    You can look at the url of the html you are trying to find. In the case of the files I listed you'd see the path start with /discussion/ and that's the folder I look in. The file you modified would be for a url that started with /messages/ or /conversations/messages/.

    But again, I highly recommend you don't modify core views like this. If you are coming from the Wordpress world you should know of plugin authors doing this type of thing and then seeing sites crippled when Wordpress updates. Unlike Wordpress, Vanilla has a lot more user-facing pages which means the site is more difficult to just branch themes by editing all of the views.

  • Options

    why not hook BeforeCommentDisplay in a themehook?

    and set $Sender->EventArguments['CssClass'] .= ' CommentBy'.urlencode(Gdn::Session()->User->Name);

    then style li.CommentBy-Todd span.Author

    what is it that you are trying to do anyway?

    grep is your friend.

  • Options
    edited August 2012

    Thanks for the answers.

    Todd – Yes, I understand that any HTML changes will be reversed when I come to upgrade. Thanks for the instructions, I will try those out.

    x00 - I didn't understand what you said about themehook and setting $Sender etc... but styling li.CommentBy-Todd is exactly the kind of thing I want to do, so I need to get that class in there somehow.

    In answer to your question about what I'm trying to do – I've changed the layout of the discussions, placing the meta info alongside the messages so that it's easier to scan down the comments without the meta detail interrupting your view between each comment (take a look). But now there's not as much width for the meta data. The site doesn't have a lot of users, but one regular has a particularly long username... so by targeting his specific meta info with CSS I can make his username narrower (slightly reduced letter spacing) so that it fits nicer into that column.

    Very very edge-case, I know! But in general, putting additional meaningful classes on containing elements allows more flexibility for forum designers / owners. A more useful example would be to put a class of the role type on the containing element, so that moderators' posts can be displayed differently (as you have on this forum, by using the .Rank-Vanilla class on the containing element to insert the Vanilla logo in the background of some comments).


  • Options

    just add

    word-wrap: break-word;

    grep is your friend.

Sign In or Register to comment.