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.

Help with views

Hey there! What should I go about editing to change the structure of my discussion layout or the post designs specifically. Thank you :). I was looking through the views but I couldn't find the right one :c.

Comments

  • whu606whu606 I'm not a SuperHero; I just like wearing tights... MVP

    @Moostachie‌

    Welcome to the community.

    All changes (or very nearly all) that you are likely to need can be made via a custom theme.

    Design issues are normally resolved via adding rules in custom.css. Layout can be edited via default.master.

    What kind of structure change were you looking to make?

    Have a look here:

    http://vanillawiki.homebrewforums.net/index.php/A_Quick-Start_Guide_to_Creating_Themes

    hgtonight
  • R_JR_J Ex-Fanboy Munich Admin

    You'll find discussion/comment related views in vanilla/applications/vanilla/views/discussion, but don't change them at that place!

    Create your custom theme and copy folder and file you like to change in there and then only change that file /themes/YourTheme/views/discussion/comment.php.

    hgtonightHazulu
  • Thank you for your help!

  • One more question, I see the discussion.php only changes the first comment, which file would I edit to edit the comments underneath? I looked around but couldn't find any file that resembles the vanilla/applications/vanilla/views/discussion/discussion.php Right now I have an edited version of that + my custom.css in my theme. Thanks again ^^.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    you need to look into all the vanilla files so you get familiar. Some files will be under the vanilla application views , like the conversations app and such.

    To change the layout, you need to edit the default.master of your theme. Editing the views in the core is not necessary.

    Please show us a screen shot of what you wish to achieve. And also what you have done and how. Otherwise it is hard to gauge exactly if you understand the advice given or if it even pertains to what you need. It may be simpler than what someone else thinks.

    peregrineHazulu
  • peregrineperegrine MVP
    edited October 2014

    ditto what vrijvlinder said. editing views often takes you down a one-way path down the wrong road, and can make upgrades more difficult (despite putting them in your customized theme). If you want an example take a look at some themes and/or plugins (which included modified views) that were written for vanilla 2.0 that no longer work in 2.1 because views and helper functions changed. Majority of changes can be made via theme hooks, css, plugins and modifying default.master.tpl

    A large majority of the time people asking "I can't find the view file to edit" are the ones who don't understand the values of theme hooks, css, plugins and modifying default.master.tpl. you may not be one of them, but then again you might be.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    vrijvlinderHazulu
  • R_JR_J Ex-Fanboy Munich Admin

    @R_J said:

    Create your custom theme and copy folder and file you like to change in there and then only change that file /themes/YourTheme/views/discussion/comment.php.

    You'll see that this file only calls a helper function "WriteComment" and that one can be found here https://github.com/vanilla/vanilla/blob/2.1/applications/vanilla/views/discussion/helper_functions.php#L43-155

    hgtonightHazulu
  • peregrineperegrine MVP
    edited October 2014

    While @r_J may be the hero of this play. The chorus ( @vrijvlinder and peregrine) is not without its value

    Plays of the ancient Greek theatre always included a chorus that offered a variety of background and summary information to help the audience follow the performance. They commented on themes, a...

    Some historians argue that the chorus was itself considered to be an actor

    The chorus represents, on stage, the general population of the particular story, in sharp contrast with many of the themes of the ancient Greek plays which tended to be about individual heroes, gods, and goddesses

    They often communicated in song form, but sometimes spoke their lines in unison. The chorus had to work in unison to help explain the play as there were only one to three actors on stage who were already playing several parts each.

    http://en.wikipedia.org/wiki/Greek_chorus

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    R_JvrijvlinderHazulu
  • HazuluHazulu New
    edited October 2014

    @R_J This is exactly what I was looking for, Big thank you ^.^;

    @vrijvlinder said:
    you need to look into all the vanilla files so you get familiar. Some files will be under the vanilla application views , like the conversations app and such.

    To change the layout, you need to edit the default.master of your theme. Editing the views in the core is not necessary.

    Please show us a screen shot of what you wish to achieve. And also what you have done and how. Otherwise it is hard to gauge exactly if you understand the advice given or if it even pertains to what you need. It may be simpler than what someone else thinks.

    Yeah, I plan to go through everything trying to find what changes what and where to edit to accomplish some of the things I wish to do. The only main thing is just finding what I need to edit, and I can't believe I missed that portion in helper_functions ;~;.

    @peregrine said:
    ditto what vrijvlinder said. editing views often takes you down a one-way path down the wrong road, and can make upgrades more difficult (despite putting them in your customized theme). If you want an example take a look at some themes and/or plugins (which included modified views) that were written for vanilla 2.0 that no longer work in 2.1 because views and helper functions changed. Majority of changes can be made via theme hooks, css, plugins and modifying default.master.tpl

    A large majority of the time people asking "I can't find the view file to edit" are the ones who don't understand the values of theme hooks, css, plugins and modifying default.master.tpl. you may not be one of them, but then again you might be.

    Is a theme hook the modified php version that goes in views? Or is it something else :o?

    Thank you everyone who responded as well, great to see a nice community surrounding this forum software. I am very impressed xD.

    EDIT: If someone can change my discussion to Answered that would be great!

  • peregrineperegrine MVP
    edited October 2014

    Is a theme hook the modified php version that goes in views? Or is it something else :o?

    It's a way of manipulating code.

    try googling vanilla and theme hooks.

    or enter "theme hooks" in search box. An example of it is in mobile theme.

    https://github.com/vanilla/vanilla/blob/2.1/themes/mobile/class.mobilethemehooks.php

    and in embed friendly and you can create your own.

    probably some info in the Documentation as well as on the wiki and the various theme tutorials.

    here is hgtonight's definition of theme hooks.
    http://vanillaforums.org/discussion/comment/196862/#Comment_196862

    here is what Todd has to say.
    http://vanillaforums.org/docs/theme-hooks

    there are lots more discussions and info on it. just requires a careful search

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    vrijvlinder
  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Theme hooks is another word for plugin. But it is called theme hooks because it plugs to your theme. It is where you would add php code to work with the default.master.tpl . It is part of the view. View means page, what you see. Controller also means page.

    Discussions controller = discussions index page

    Categories controller= categories index page

    etc.

    If you look at a theme that is based on tpl then it may have a theme hooks file which is where all the stuff would be, such as the links to the menu and the modules it may be using ... It is handy to use when adding php to the template.

  • R_JR_J Ex-Fanboy Munich Admin

    You have more than one possibility to change the look and feel of Vanilla. Most people new to Vanilla want to change "templates". Closest to templates are the views of Vanilla. Vanilla is based on a MVC framework called Garden. Most views are in the /applications/blablabla/views folder.
    What many people refer to as "widget" is a module and you'll find them in /applications/blablabla/modules but it takes some skill to change them.
    When talking about applications, you have three main applications in a vanilla standard installation:

    1. dashboard is there to manage everything that is needed for having an admin section. The most interesting part for you will be that it handles users and their profiles
    2. vanilla is the forum. It adds categories, discussions and comments
    3. conversations is the private messaging system

    So whenever you look for a view, think "where" you are looking at ;)

    Now, coming back to themehooks, you can either override a view by creating a file with the same name in your theme folder, or you can enhance an existing view by using the events that are fired in views. Look at the source of /applications/vanilla/views/discussion/helper_functions.php and you'll find the following lines in the function WriteComment:

    $Sender->FireEvent('BeforeCommentDisplay');
    $Sender->FireEvent('BeforeCommentMeta');
    $Sender->FireEvent('AuthorPhoto');
    $Sender->FireEvent('AuthorInfo');
    $Sender->FireEvent('CommentInfo');
    $Sender->FireEvent('AfterCommentBody');
    $Sender->FireEvent('AfterComment');
    

    Well if you are a html guy, that will not help you in any way, but copy the following lines into your custom theme folder and name it like that "class.YourThemeNamethemehooks.php" (don't forget to change "YourThemeNameThemeHooks" in the first line of the file, too. And you'll have to delete the space between "<" and "!--")

    class YourThemeNameThemeHooks implements Gdn_IPlugin {
       // don't care about this...
       public function Setup() {
       }
       // ... or that
       public function OnDisable() {
          return TRUE;
       }
       // the interesting part starts here!
       public function DiscussionController_BeforeCommentDisplay_Handler ($Sender) {
          echo '< !-- $Sender->FireEvent("BeforeCommentDisplay"); -->';
       }
    
       public function DiscussionController_BeforeCommentMeta_Handler ($Sender) {
          echo '< !-- $Sender->FireEvent("BeforeCommentMeta"); -->';
       }
    
       public function DiscussionController_AuthorPhoto_Handler ($Sender) {
          echo '< !-- $Sender->FireEvent("AuthorPhoto"); -->';
       }
    
       public function DiscussionController_AuthorInfo_Handler ($Sender) {
          echo '< !-- $Sender->FireEvent("AuthorInfo"); -->';
       }
    
       public function DiscussionController_CommentInfo_Handler ($Sender) {
          echo '< !-- $Sender->FireEvent("CommentInfo"); -->';
       }
    
       public function DiscussionController_AfterCommentBody_Handler ($Sender) {
          echo '< !-- $Sender->FireEvent("AfterCommentBody"); -->';
       }
    
       public function DiscussionController_AfterComment_Handler ($Sender) {
          echo '< !-- $Sender->FireEvent("AfterComment"); -->';
       }
    }
    

    When you're finished, reload a discussion and look at the html source ;)
    Change any of the functions echo... to echo 'CommentID = ', $Sender->EventArguments['Comment']->CommentID; to get an idea what you can do with theme hooks.

    But using custom views or themehooks is almost only necessary if you want to add content to the view. If you simply like to have a different style, you should prefer a pure CSS solution.

    hgtonightperegrineHazulu
Sign In or Register to comment.