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.

How to change url of Contact plugin

ChanuxChanux Admin of Geek.lk ✭✭

@vrijvlinder This is a verry usefull and nice one. i have a problem.

How to change url of Contact plugin

  1. as example deffauld url is Domain.com/plugin/contact. but i want to add Domain.com/plugin/chanux.

  2. can we add this without Plugin part.. ex Domain.com/chanux

Comments

  • TamaTama United Kingdom ✭✭✭

    There was an error rendering this rich post.

    hgtonightUnderDog
  • ChanuxChanux Admin of Geek.lk ✭✭

    @Tama i think this is the answer for 2nd question. im using it. but i have no idea how to use it in plugin

    This is my URL http://geek.lk/plugin/page/games i routed it to http://geek.lk/games

  • hgtonighthgtonight ∞ · New Moderator

    If you are looking to add a route pragmatically, check out SetRoute in class.router.php.

    E.g:

    $Router = Gdn::Router();
    $Router->SetRoute('chanux', 'plugin/chanux', 'Internal');
    

    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.

    Chanux
  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    I put the instructions on the plugin page , replace the setup function with this one. at the very end

    public function Setup() {
      
                 $matchroute = '^Chanux(/.*)?$';
                 $target = 'plugin/Contact$1';
            
                 if(!Gdn::Router()->MatchRoute($matchroute))
                      Gdn::Router()->SetRoute($matchroute,$target,'Internal'); 
              
        }
    
    }
    
    Chanux
  • ChanuxChanux Admin of Geek.lk ✭✭

    @vrijvlinder i tried and couldn't. you have created your plugin url without routing.

    i mean domain.com/plugin/contact

    i want to create a new plugin with custome page. when enable the plugin, should create a additional page like domain.com/plugin/chanux or domain.com/chanux

    i dont want to use custome page plugin or Routing system. you created it using few lines in Default.php

    could you help me to create my own page ??

  • hgtonighthgtonight ∞ · New Moderator

    @Chanux You can create a new "page" on any controller using the create magic method.

    E.g:

    public function PluginController_Chanux_Create($Sender) {
      // Do something
      $Sender->Render();
    }
    

    This will "create" a url at http://www.example.com/plugin/chanux.

    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.

    Chanux
  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    @Chanux said:
    vrijvlinder I tried and couldn't. you have created your plugin url without routing.

    I don't think so Chanux, I use it on 6 forums without problems and I used that code up there to route.

    If it does not work you must have done something wrong. The link it under this function, you would need to change this part from contact to whatever. and also add the route code from above.

    public function Base_Render_Before($Sender) {
            $Session = Gdn::Session();
           if ($Sender->Menu) {
               $Sender->Menu->AddLink('Contact',T('Contact'), 'plugin/Contact');
             }
    
    
    ChanuxUnderDog
  • ChanuxChanux Admin of Geek.lk ✭✭

    @hgtonight yes. that is the answer.. Thanx

    @vrijvlinder Problem solved. Thanx

    UnderDog
Sign In or Register to comment.