Dynamic routing

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

Dynamic routing

Post by Sajaki » Tue Feb 06, 2018 11:42 am

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
Jr. Extension Validator
Posts: 636
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: Dynamic routing

Post by GanstaZ » Tue Feb 06, 2018 2:08 pm

Well.. you should start from here load method .
"When answer lies in the question,.. question becomes redundant!"

User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 4707
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Dynamic routing

Post by VSE » Thu Feb 08, 2018 12:08 am

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
Dictated but not read.
Official phpBB Extensions My Extensions & MODs
Please do not PM me for support.

User avatar
mrgoldy
Jr. Extension Validator
Posts: 734
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: Dynamic routing

Post by mrgoldy » 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 :-)
Formerly known as posey.
''Proud member of the Studio"

User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 4707
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Dynamic routing

Post by VSE » Sat Feb 10, 2018 1:07 am

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.
Dictated but not read.
Official phpBB Extensions My Extensions & MODs
Please do not PM me for support.

User avatar
mrgoldy
Jr. Extension Validator
Posts: 734
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: Dynamic routing

Post by mrgoldy » Sat Feb 10, 2018 1:23 pm

Alright, thanks for the clarification.
I'll dig into it aswell and fiddle with it.
Cheers
Formerly known as posey.
''Proud member of the Studio"

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 » Thu Feb 15, 2018 7:10 pm

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”

Who is online

Users browsing this forum: No registered users and 5 guests