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

Instructions: How to Make a prettyURL for a plugin

peregrineperegrine MVP
edited March 2013 in Feedback

How to Make a prettyURL for a plugin

e.g. in this case for the membership enhanced plugin - A similar routine can be done with extrapage plugin, etc.

to display

http://myforum.com/members

instead of

http://myforum.com/plugin/MembersListEnh

In you default.php or class.YOURPLUGIN.php

public function OnDisable() {
     // delete route when plugin is disabled
         $matchroute = '^members(/.*)?$';
          $target = 'plugin/MembersListEnh$1';
       Gdn::Router()-> DeleteRoute($matchroute,$target,'Internal'); 

}
public function Setup() {
         // insert route when plugin is enabled.  It is now displayed in dashboard - routes
         $matchroute = '^members(/.*)?$';
         $target = 'plugin/MembersListEnh$1';

         if(!Gdn::Router()->MatchRoute($matchroute))
              Gdn::Router()->SetRoute($matchroute,$target,'Internal'); 


}

see this thread for the participants who participated in the underlying features of the above guide.

feel free to add it to the wiki.

I will update the plugin in a week or two, I am making other changes so read the following commeont and the following comment if you are in a rush to change the plugin.

http://vanillaforums.org/discussion/23173/making-route

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

Tagged:

Comments

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    Thanks For this Im really happy! Now...

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    Again, I don't get this but Ill explain why:

    Added my code to class.PLUGIN.php

    $MembersListEnhModel = new Gdn_Model('User');
            $Sender->UserData = $MembersListEnhModel->SQL
            ->Select('*')
            ->From('User u')
            ->OrderBy("u.$UserField",$SortOrder)
            ->Where('Deleted',false)
            ->Limit($Limit, $Offset)
            ->Get();
           RoleModel::SetUserRoles($Sender->UserData->Result());
           return $Sender->UserData;
    }
    
    }    
         
        public function GetMembersCount(){
         $MembersListEnhModel = new Gdn_Model('User');
        return $MembersListEnhModel->SQL
            ->GetCount('User');
         
        }
    
     public function OnDisable() {
        // delete route when plugin is disabled
        $matchroute = '^members(/.*)?$';
        $target = 'plugin/MembersListEnh$1';
        Gdn::Router()-> DeleteRoute($matchroute,$target,'Internal');
        }
        public function Setup() {
        // insert route when plugin is enabled. It is now displayed in dashboard - routes
        $matchroute = '^members(/.*)?$';
        $target = 'plugin/MembersListEnh$1';
        if(!Gdn::Router()->MatchRoute($matchroute))
        Gdn::Router()->SetRoute($matchroute,$target,'Internal');
        }
    
    
    
      
      }
    

    I see it in the routes, but when I do /community/members/ I get this

    
    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 76 bytes) in /home/rpaso604/public_html/dragonx.net/community/library/core/class.dispatcher.php on line 486 
    

    Did I add this to wrong the place?

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    You have a loop going on..that is using up the allocated memory.

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    @vrijvlinder said:
    You have a loop going on..that is using up the allocated memory.

    How may I fix this? Loop?

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
Sign In or Register to comment.