HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Custom Vanilla Theme

Hi! I have some questions:
1. I know panel configurate in config.default.php, but I can't enable/disable modules. Can anyone sent me example?
2. I create new theme with my module views and layout, but I can redefine only layout. What I must do foe redefine modules views? Please, take me examples.

Thanks.

Comments

  • When you create a new theme, create also a file \themes\YourFancyTheme\class.themehooks.php with following code:

    <?php defined("APPLICATION") or die;
    class YourFancyThemeThemeHooks implements Gdn_IPlugin {
        // this two functions do nothing here, but you need to implement them!  
        public function setup () {
            return true;
        }
        public function onDisable () {
            return true;
        }
    
        // this will be called on every page
        public function base_render_before ($sender) {
            // don't show categories
            unset($sender->Assets['Panel']['CategoriesModule']);
        }
    
        // only done when looking at a discussion
        public function discussionController_render_before ($sender) {
            // don't show the In this Discussion module
            unset($sender->Assets['Panel']['InThisDiscussionModule']);
        }
    }
    
  • Thank you R_J! It's great solution. What else do I need to know to create new theme?

  • You didn't need to know that for a nice theme. It all depends on what you try to achieve. Just start your theme and whenever you get stuck do a research on this forum for someone who asked a similar question and if you find nothing, don't hesitate to ask. If you can give a visual an example of what you try to achieve you make answering more easily, but if you describe your problem well enough, it shouldn't be a problem to offer a solution, either.

  • @R_J said:
    When you create a new theme, create also a file \themes\YourFancyTheme\class.themehooks.php with following code:

    <?php defined("APPLICATION") or die;
    class YourFancyThemeThemeHooks implements Gdn_IPlugin {
        // this two functions do nothing here, but you need to implement them!    
        public function setup () {
            return true;
        }
        public function onDisable () {
            return true;
        }
    
        // this will be called on every page
        public function base_render_before ($sender) {
            // don't show categories
            unset($sender->Assets['Panel']['CategoriesModule']);
        }
    
        // only done when looking at a discussion
        public function discussionController_render_before ($sender) {
            // don't show the In this Discussion module
            unset($sender->Assets['Panel']['InThisDiscussionModule']);
        }
    }
    

    How I can anable Module In content, also I use echo Gdn_Theme::Module('SideMenuModule');, but in profile edit page that dosn't work

  • edited March 2015

    Config didn't work, also $this->AddModule('SideMenuModule', 'Content');

  • @phalc0nline said:
    How I can anable Module In content, also I use echo Gdn_Theme::Module('SideMenuModule');, but in profile edit page that dosn't work

    You need to hook into the controller and add the module. E.g.:

    public function profileController_render_before($sender) {
        $sender->addModule('SideMenuModule', 'Content');
    }
    

    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.

  • edited March 2015
    public function profileController_render_before($sender)
        {
            unset($sender->Assets['Panel']['ProfileFilterModule']);
            unset($sender->Assets['Panel']['OnlineNowModule']); //doesn't work
            unset($sender->Assets['Panel']['SideMenuModule']);
            $sender->addModule('SideMenuModule', 'Content'); //doesn't work
        }
    

    Usage echo Gdn_Theme::Module('SideMenuModule');

    What I do wrong?

  • If you are unsetting a module that is added via a plugin, you need to make sure your code runs after the module gets added. Or modifying the plugin to not add the module in the first place.

    Why are you looking to add the SideMenuModule to the Content asset?

    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.

  • edited March 2015

    @hgtonight said:

    Why are you looking to add the SideMenuModule to the Content asset?

    I must have navigation links in every content profile edit view like Select tag. Do you propose write inline code in view without module?

  • @phalc0nline said:
    I must have navigation links in every content profile edit view like Select tag. Do you propose write inline code in view without module?

    I don't quite understand what you are asking. Perhaps a screenshot showing what you are trying to accomplish would help me.

    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.

  • I want have this links in content

    2.png 96.1K
    1.png 107.9K
  • I want add to content tabs

Sign In or Register to comment.