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.
Options

Creating a Template

Hey and first of all i'd like to report back after many years of abstinence :)

So i'm about to create a theme and i need to change and rearange the whole structure of the recent discussions for example, therefore i need to alter the base files since to alter the css or the default.master template wouldn't be enough anymore for my special venture.

So what is the exact procedure? To copy & paste the original vanilla files i'd like to change into the themes/mytheme folder and go for it?

Thanks :)

Best Answer

Answers

  • Options
    whu606whu606 I'm not a SuperHero; I just like wearing tights... MVP
    edited April 2016

    @keesha

    Without knowing exactly what you want, it's not easy to say, but you can customise views.

    See here: http://docs.vanillaforums.com/theming/views/

    Note that you need to keep the same folder structure within your theme.

  • Options

    Hi @whu606 ,

    So just as i thought its just copy the main view structure into the view structure of my theme.

    All i'm trying to do right now is to split up the single row column of each topic in the recent discussions section into three horizontal columns like:

    from:

    I______________________I

    into:

    I_______I_______I_______I

  • Options
    hgtonighthgtonight ∞ · New Moderator

    @keesha said:
    Hi @whu606 ,

    So just as i thought its just copy the main view structure into the view structure of my theme.

    All i'm trying to do right now is to split up the single row column of each topic in the recent discussions section into three horizontal columns like:

    from:

    I______________________I

    into:

    I_______I_______I_______I

    This doesn't require a view override.

    .DataList .Item, .NarrowList .Item {
        display: inline-block;
        width: 30%;
    }
    

    CSS is very powerful and vastly preferred over overrides.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    @hgtonight said:

    @keesha said:
    Hi @whu606 ,

    So just as i thought its just copy the main view structure into the view structure of my theme.

    All i'm trying to do right now is to split up the single row column of each topic in the recent discussions section into three horizontal columns like:

    from:

    I______________________I

    into:

    I_______I_______I_______I

    This doesn't require a view override.

    .DataList .Item, .NarrowList .Item {
        display: inline-block;
        width: 30%;
    }
    

    CSS is very powerful and vastly preferred over overrides.

    Hi :)

    I need do implement additional functions into those columns otherwise you would be right.

  • Options
    hgtonighthgtonight ∞ · New Moderator

    @keesha said:

    Hi :)

    I need do implement additional functions into those columns otherwise you would be right.

    What kind of functions? Themes are not the way to add functionality. Plugins are best for that.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    @hgtonight said:

    @keesha said:

    Hi :)

    I need do implement additional functions into those columns otherwise you would be right.

    What kind of functions? Themes are not the way to add functionality. Plugins are best for that.

    I try to add excerpts under each discussion title since there doesn't seem to be a working plugin for vanilla for this job.

    To code a plugin is beyond my abilities right now, i'm okay with pure frontend stuff as far as its basic HTML, PHP and CSS but that's it. :)

  • Options
    hgtonighthgtonight ∞ · New Moderator

    @keesha said:

    I try to add excerpts under each discussion title since there doesn't seem to be a working plugin for vanilla for this job.

    To code a plugin is beyond my abilities right now, i'm okay with pure frontend stuff as far as its basic HTML, PHP and CSS but that's it. :)

    This makes no sense. How are you going to create an excerpt for each discussion if you don't know how to use the framework?

    https://vanillaforums.org/addon/example-plugin

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    @keesha said:
    To code a plugin is beyond my abilities right now, i'm okay with pure frontend stuff as far as its basic HTML, PHP and CSS but that's it. :)

    It is far more simple than you think. If you know basic PHP, you will have no problems

    If you are creating a theme, add a themehooks file:

    <?php
    
    class YourThemeNameThemeHooks implements Gdn_IPlugin {
    
        public function setup() {
            return true;
        }
    
        public function onDisable() {
            return true;
        }
    
        // Your code starts here
    }
    

    Then activate the plugin "eventi". It will show you the name of the events that you need. Simply spoken: whenever an event is fired, you are able to insert code or change the output. If you are not quite sure how to get/change information, just ask. Here are some examples that change the way the discussions helper functions work.

    If you look through the file, you'll find a line $Sender->fireEvent('BetweenDiscussion'); and here is how you can insert code at this place:

    public function discussionsController_betweenDiscussion_handler($sender, $args) {
        // Famous "Hello World" beginner example...
        echo '<h1>Hello World!</h1>;
    }
    

    And there is also the event "BeforeDiscussionName" (I skip the php code around it). You'll find several similar looking lines like that before the call $Sender->EventArguments['something'] = ...;. Those variables are accessible in the plugin/themehooks file.

    public function discussionsController_beforeDiscussionName_handler($sender, $args) {
        // Changes the discussion title
        $args['Discussion']->Name = $args['FirstUser']->Name.': '.$args['Discussion']->Name;
    } 
    

    You get the pattern? When there is a fireEvent, you can insert html or change the output. Just try it.

    Changing core files is more work in the long run, because you have to update all changes when a new version of Vanilla is out.

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    The themehooks file must be in your theme folder as class.yourthemenamethemehooks.php (see mobile theme as an example)

  • Options

    @R_J said:
    The themehooks file must be in your theme folder as class.yourthemenamethemehooks.php (see mobile theme as an example)

    Hi @R_J ,

    Thank's for the help, i'm going to try your little tutorial ASAP.

  • Options
    rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    Hi @keesha - I hope you were successful in your plugin writing to get excerpts. If not you may take a look at the source of DiscussionExtract plugin which extract content and displays it in discussion lists.

Sign In or Register to comment.