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

How to get needed parameters and info in plugin (request-arguments)?*

wzttest1wzttest1 New
edited August 2013 in Vanilla 2.0 - 2.8

Hello:

I'm developing plugin for vanilla.I want to know how to get the parameters in plugin to know what controller/method/forum/thread/reply has been read or operated in current page?
Now I can only get some info by the $_REQUEST['p'] parameter,but it is not enough,it is not reliable in some rewrite rule applied sites.

I need judge these info in my plugin,so I can control what need to do in my plugin.

Thanks.

Comments

  • Options

    what you are looking for is called RequestArguments, you are right in thinking you should avoid using $_REQUEST or $_GETas this should be abstracted.

    it depends on contents but usually in a controller hook you would use

    $Sender->RequestArgs it is an array of arguments. so if you have example request:

    /discussion/love/param1/param2

    RequestArgs will contain [param1,param2]

    If you just want to the check the request method use '$Sender->RequestMethod that will contain love method. If there is basically no method it will usefully be 'index', but you can debug to find out.

    If you want the controller name, such as when you are using Base_ you can use

    strtolower($Sender->ControllerName) which will produce discussioncontroller

    If you just want the request path use $Sender->Request->Path() or Gdn::Request()->Path() for short this will contain /discussion/love/param1/param2

    grep is your friend.

  • Options

    Hello x00:

    Great.
    Deeply Thank You!
    This is what I want.
    You are so handsome.:)

Sign In or Register to comment.