Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Vanilla 2.6 is here! It includes security fixes and requires PHP 7.0. We have therefore ALSO released Vanilla 2.5.2 with security patches if you are still on PHP 5.6 to give you additional time to upgrade.

Which way is better to do an application?

peregrineperegrine MVP
edited July 2012 in Development

It seems that the technique used in Members List 1.1 is clearly much easier to add an application, then using custom pages plugin or writing an application and placing in the applications directory. I hadn't seen this technique used before,but I like it.

Any comments by the vanilla developers or any others?

also a question about this statement. Where and what does default reference? And can you explain this statement a little bit better.

$Sender->MasterView = 'default';

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

Comments

  • TimTim Operations Vanilla Staff

    How about elaborating on "the technique used in Members 1.1"? I have no idea what that is.

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • TimTim Operations Vanilla Staff

    'default' refers to the master template name. Look in applications/dashboard/views

    Vanilla Forums COO [GitHub, Twitter, About.me]

    peregrineUnderDog
  • peregrineperegrine MVP
    edited July 2012

    thanks Tim. the plugin is here.
    http://vanillaforums.org/addon/memberslist-plugin

    essentially just adds a menu item in the plugin
    and a view

    class MembersListPlugin extends Gdn_Plugin{

          public function Base_Render_Before($Sender){
            if(Gdn::Session()->IsValid()){
             $Sender->Menu->AddLink('Members', T('Members'), 'plugin/MembersList/');
            }
          }
    
         public function PluginController_MembersList_Create($Sender){
            if(Gdn::Session()->IsValid()){
                $Sender->ClearCssFiles();
                $Sender->AddCssFile('style.css');
                $Sender->MasterView = 'default';
    
              $Sender->UserData = Gdn::SQL()->Select('User.*')->From('User')->OrderBy('User.Name')->Where('Deleted',false)->Get();
              RoleModel::SetUserRoles($Sender->UserData->Result());
    
                $Sender->Render(dirname(__FILE__).DS.'memberlist.view.php');
            }
            }
    
            public function Setup(){
            }
    
        }
    

    Which seems so easy. compared to doing a custom page messing with routes, or fooling around in the application directory.

    My question is primarily because - although I understand some of the basics of vanilla, many things still elude me.

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

  • Tim said:
    'default' refers to the master template name. Look in applications/dashboard/views

    so if I wanted to just to understand this better.

    create a file called peregrine.master.php

    and set the view this way to use the peregrine.master.php

    $Sender->MasterView = 'peregrine';

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

  • LincLinc Director of Development Detroit Vanilla Staff

    My test is that I build an application if I need multiple controllers (multiple sets of grouped actions). Otherwise, I use a plugin.

    peregrineUnderDogTim
  • ToddTodd Chief Product Officer Vanilla Staff

    We create very few new applications and when we do they are major. Plugins can do a lot and is what I'd recommend. The render call in the above function isn't exactly how I'd do it.

    $Sender->Render('MemberList', '', 'plugins/MemberList);
    

    In this case you'd put the view in /plugins/MemberList/views/memberlist.php.

    UnderDogTimperegrine
  • TimTim Operations Vanilla Staff
    edited July 2012

    But yeah, the way you showed there is exactly right: attach a new method to the PluginController and use it as your own entry point.

    What @Todd said about the view is 100% right and also applies beyond this example: If you find yourself doing dirname(FILE) anywhere, you've probably done it wrong and should be using a constant like PATH_PLUGINS, or a convenience method.

    Vanilla Forums COO [GitHub, Twitter, About.me]

    peregrineUnderDog
  • Wow! hit the trifecta of developers here. thanks.

    @csakip thanks for the plugin. learned alot on this one.

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

    UnderDog
Sign In or Register to comment.