Dynamic routing

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
Sajaki
Registered User
Posts: 1390
Joined: Mon Mar 02, 2009 1:41 pm
Location: Amsterdam
Contact:

Dynamic routing

Post by Sajaki »

hi all,

i have a question regarding rhe routing file in phpbb pages extension. what is "dynamic routing" ? i couldn't find this way of doing it in the tutorials.
https://github.com/phpbb-extensions/pag ... outing.yml

Code: Select all

# Dynamic routing for Pages 2.0.x
phpbb_pages_dynamic_controller:
    resource: phpbb_pages_new_controller # can be any name, it is not used, but must be present
    type: phpbb_pages_route

# Legacy routing from Pages 1.0.x, for backwards compatibility
phpbb_pages_main_controller:
    path: /page/{route}
defaults: { _controller: phpbb.pages.controller:display }
User avatar
GanstaZ
Registered User
Posts: 1187
Joined: Wed Oct 11, 2017 10:29 pm
Location: GZOverse

Re: Dynamic routing

Post by GanstaZ »

Well.. you should start from here load method .
Usus est magister optimus! phpBB pre-Triton & latest php environment.
When answer lies in the question, question becomes redundant!
User avatar
MattF
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 5859
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman

Re: Dynamic routing

Post by MattF »

its a complicated way to set up routes in phpBB 3.2 where your route's url can be from the path "/{var}" so you don't need to use something like "/page/{var}" as Pages had to do in phpBB 3.1
Formerly known as VSEMy ExtensionsPlease do not PM me for support.
User avatar
mrgoldy
Former Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs
Contact:

Re: Dynamic routing

Post by mrgoldy »

Any chance you could elaborate a bit more on this, VSE?
Cause this is a very interesting approach.

Haven't tried anything like this myself, but it looks very interesting! However I'm going to guess that I ( and perhaps others ) could do with a bit more explanation as to what you're exactly doing and how it's properly done. Perhaps with the commonly made mistakes.

Appreciated and thanks in advance :-)
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
User avatar
MattF
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 5859
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman

Re: Dynamic routing

Post by MattF »

posey wrote: Thu Feb 08, 2018 1:03 am Any chance you could elaborate a bit more on this, VSE?
Cause this is a very interesting approach.

Haven't tried anything like this myself, but it looks very interesting! However I'm going to guess that I ( and perhaps others ) could do with a bit more explanation as to what you're exactly doing and how it's properly done. Perhaps with the commonly made mistakes.

Appreciated and thanks in advance :-)
That code was provided by Nicofuma. I do not really understand how it works, but you can find how it was implemented for Pgaes.
https://github.com/phpbb-extensions/pag ... 292c67c1f8

The main thing is the custom routing page loader class in Pages. And you can see that class is defining new routes for every "Page" that is created by the pages extension (phpbb_page_dynamic_route_$id) which are being used instead of whatever the normal routing methods are. Which is why they are "dynamic" because these routes are generated on the fly and cached.
Formerly known as VSEMy ExtensionsPlease do not PM me for support.
User avatar
mrgoldy
Former Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs
Contact:

Re: Dynamic routing

Post by mrgoldy »

Alright, thanks for the clarification.
I'll dig into it aswell and fiddle with it.
Cheers
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
nicofuma
3.2 Release Manager
3.2 Release Manager
Posts: 546
Joined: Sun Apr 13, 2014 1:47 am
Location: Grenoble - France

Re: Dynamic routing

Post by nicofuma »

Here is a proper explanation in Symfony's documentation :) https://symfony.com/doc/2.8/routing/cus ... oader.html
Member of phpBB Development-Team
No Support via PM
Post Reply

Return to “Extension Writers Discussion”