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

Customize plugin view

edited February 2015 in General Banter

Hi!
Please give link for topic or code example how to change correctly plugin view?

Tagged:

Comments

  • Options
    hgtonighthgtonight ∞ · New MVP

    Welcome to the community!

    Are you looking to override a current plugin's view, or are you creating a plugin and you want to know how to create a custom view?

    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:
    Welcome to the community!

    Are you looking to override a current plugin's view, or are you creating a plugin and you want to know how to create a custom view?

    I'm looking for how override a current plugins view. I know what I can change plugin view in /plugins/pluginName, but it's wrong way. Can you give me an advice?

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    Overriding a plugins view is not possible in most cases. There are different ways a view is fetched but one common way is to specify the path to the file. In such cases you wouldn't be simply able to change anything without changing the plugins source.
    Although I'm quite sure @hgtonight knows a magic trick to achieve it nevertheless... (maybe by implementing your own FetchViewLocation)

    I'd advice you to either make a better suggestion to the plugin author if you have an improvement or to copy the plugin from folder "OldPluginName" to "OldPluginNamePlus" "OldPluginNameMine" or "OldPluginName2" or "NewPluginName" or whatever.
    Do a case sensitive search for "OldPluginName", "oldpluginname" and maybe also "oldPluginName" and replace them with the corresponding "NewPluginName", "newpluginname", "newPluginName". Rename all files regarding to the name change. Change the description and give credit to the original plugin and that's it.

    But if you tell us what plugin you are talking about you can be sure to get more detailed advice.

  • Options

    plugin name "Online Now".

  • Options
    hgtonighthgtonight ∞ · New MVP

    Online now does not use a view for it's module. Modules should use views if possible.

    You will have to fork and edit it how you want. You need to edit the OnlineNowModule::ToString() method. You can find it in /plugins/OnlineNow/class.onlinenowmodule.php.

    Unless @R_J can come up with some novel idea. ;)

    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
    x00x00 MVP
    edited February 2015

    Many of my plugins allow this, if you are contributing back to a plugin this is typically the code that I use.

        public function ThemeView($View){
            $ThemeViewLoc = CombinePaths(array(
                PATH_THEMES, Gdn::Controller()->Theme, 'views', $this->GetPluginFolder()
            ));
    
            if(file_exists($ThemeViewLoc.DS.$View.'.php')){
                $View=$ThemeViewLoc.DS.$View.'.php';
            }else{
                $View=$this->GetView($View.'.php');
            }
    
            return $View;
        }
    

    so under theme the override would be views/plugins/PluginName/viewname.php

    use

    $Sender->View = $this->ThemeView('viewname');
    $Sender->Render();
    

    grep is your friend.

Sign In or Register to comment.