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

Making Route

SrggamerSrggamer HardCore Gamer ✭✭✭

How can I do this?

switch($FormValues['Task']){ case 'StoreConfig': foreach ($FormValues As $FormIndex => $FormValue) if(!in_array($FormIndex,array('Task','TransientKey','hpt','Save'))) $Settings['Plugins.MarketPlace.'.$FormIndex]=$FormValue; if(!$Sender->Form->ErrorCount()){ Gdn::Router()->DeleteRoute('^'.C('Plugins.MarketPlace.StoreURI','store').'(/.*)?$'); SaveToConfig($Settings); Gdn::Router()->SetRoute('^'.C('Plugins.MarketPlace.StoreURI','store').'(/.*)?$','vanilla/marketplace$1','Internal'); } break;

Because Im trying to use the members list, But am trying to make it so that instead of pathway /plugin/memberslistehn to /community/members.

Comments

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    @x00 This is from your Market Place plugin :)

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    I don't understand , You want to make a clone of Market Place and call it something else ?

    Here is how to make a new Route

    http://vanillaforums.org/docs/routes

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    @vrijvlinder said:
    I don't understand , You want to make a clone of Market Place and call it something else ?

    Here is how to make a new Route

    http://vanillaforums.org/docs/routes

    No, I simply want another plugin to have a different route.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    coud you elaborate by posting how you think it could be done?

    Plugin A is here, but I want to get it from somewhere else? I have trouble with the logic sorry ...

  • Options
    businessdadbusinessdad Stealth contributor MVP

    @Srggamer said:
    No, I simply want another plugin to have a different route.

    Simple question: what would you like to route to what? It's not so difficult to do, if you have a clear source and destination in mind.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    he is trying to :

    trying to make it so that instead of pathway /plugin/memberslistehn to /community/members.

    my logic tells me in order to route something it must be located somewhere specific. Plugins are in the plugin department, in order to change that, the plugin would have to reside in the place you want to call it from no?

  • Options
    businessdadbusinessdad Stealth contributor MVP
    edited March 2013

    @vrijvlinder said:
    my logic tells me in order to route something it must be located somewhere specific. Plugins are in the plugin department, in order to change that, the plugin would have to reside in the place you want to call it from no?

    If I understood your question, not really. I create routes for my plugins all the time, to "prettify" the URLs, and they work well. :)

    Here's a route that should do what @Srggamer wants (untested, but it should work):
    Route: ^community/members(/.*)?$
    Target: plugin/memberslistehn/?$1

    @Srggamer are you sure that it's memberslistehn and not memberslistenh?

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    so Target tells what to fetch and from where?

  • Options
    peregrineperegrine MVP
    edited March 2013

    so Target tells what to fetch and from where?

    why did I know you were going to say this :)

    the route is what you are reading. the stuff in parenthesis is reinterpreted to $1 and
    appended onto the target.

    if you shoot an arrow you hit the target - the destination.

    @businessdad said:

    If I understood your question, not really. I create routes for my plugins all the time, to >"prettify" the URLs, and they work well. :)

    Here's a route that should do what @Srggamer wants (untested, but it should work):

    Route: ^community/members(/.*)?$
    Target: plugin/memberslistehn/?$1

    good idea @businessdad,

    the route changing is easier than writing a new app, but i learned some more app stuff too :)

    @Srggamer

    I modifed it a bit and the rest of the changes you need.

    Route: ^community/members(/.*)?$
    Target: plugin/MembersListEnh/?$1

    then change memtable in the views folder in the plugin.

    line 31 -

    $MColUrl = 'community/members/p1';

    line 72 or so

    'community/members' . '/{Page}' . '&sort=' . $SortOrder . '&ufield=' .$UserField

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

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited March 2013

    why did I know you were going to say this :)

    lol it must be love no? Don't answer that I can't take rejection kindly..... ;)

    if you shoot an arrow you hit the target - the destination.

    That is what I gather it means and is why I asked coz the logic is not clear to me.
    If I understood the OP (and that I am not sure I do) he wants the opposite .

    Maybe I need a flowchart lmao

  • Options
    peregrineperegrine MVP
    edited March 2013

    no he want a pretty url. Ya Rastaman vibration. without it saying plugin in the url.

    so

    http://myforum.com/community/members

    instead of

    http://myforum.com/plugin/MembersListEnh

    also

    the lines I added clean up the interior links in the memtable.php, and will work (as long as the route is applied).

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

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited March 2013

    Well when you put it like that it makes total sense ! Thanks for clearing it up then :)

    @Srggamer will be pleased I am sure.

  • Options

    in Setup()

    try

    if(!Gdn::Router()->MatchRoute('^community/members(/.*)?$'))
          Gdn::Router()->SetRoute('^community/members(/.*)?$','plugin/memberslistehn$1','Internal');
    

    grep is your friend.

  • Options
    businessdadbusinessdad Stealth contributor MVP

    @vrijvlinder said:
    so Target tells what to fetch and from where?

    You can interpret it like this: when User asks for Route, let's do as if he asked for Target.

    They are Regular Expressions and, as @peregrine wrote, the syntax allows you to "tag" parts of the source expression and place it somewhere in the Target one.

    @x00 Thanks for adding the code to automatically add the Routes on plugin setup. That's the same I use in most of my plugins, it's indeed so easy.

    By the way, I just would like to suggest @Srggamer, and anyone who creates routes for their plugin, the golden rule of "cleaning after yourself". That is, make sure that you delete the Routes when the plugin is disabled.

    I'm on mobile and I don't have the code handy, but I think the command should be Gdn::Router ()-> DeleteRoute (), or something like that.

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    Thanks @all for these responses I should have used more correct terminology while describing what I wish to accomplish thanks.

  • Options

    @Srggamer said:
    Thanks all for these responses I should have used more correct terminology while describing what I wish to accomplish thanks.

    PLs document it on the wiki, what you have in this thread

    There was an error rendering this rich post.

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    @UnderDog said:
    PLs document it on the wiki, what you have in this thread

    I dont get what you are saying.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    @Srggamer
    He wants you to please help document this stuff in the Vanilla Wiki so as to help others in return.

    http://vanillawiki.homebrewforums.net/index.php/Main_Page

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    @vrijvlinder said:
    Srggamer
    He wants you to please help document this stuff in the Vanilla Wiki so as to help others in return.

    http://vanillawiki.homebrewforums.net/index.php/Main_Page

    Sure,

Sign In or Register to comment.