Difference between revisions of "Modifying URL's"

From AV Scripts Wiki
Jump to: navigation, search
Line 34: Line 34:
  
 
After you've made your changes, clear the caches in the admin panel. Also if you enabled developer mode on your live website, make sure to disable it again.
 
After you've made your changes, clear the caches in the admin panel. Also if you enabled developer mode on your live website, make sure to disable it again.
 +
 +
 +
[[Category:Developer]]

Revision as of 09:26, 8 May 2015

You might want to modify the URL structure of certain pages to suit your personal tastes. All URL's can be overwritten in AVCMS using a config file called routes.yml placed into the webmaster/config directory.

Finding the route to modify

"Routes" are the name given to the definition of a URL structure. The first thing you will need to do is find the name of the route you want to modify. The easiest way to do this is to enable Developer Mode and in the developer bar at the bottom of all pages, find the area that looks like:

 GamesController :: playGameAction via play_game

The key part here is the "via [route name]". In the example above the route name is "play_game".

That's the route name found, now you need to find what the Bundle that route belongs to is called. For many things it'll be quite obvious, if the route is the play game page you probably know the route belongs to the "Games" bundle for example. If you're not sure, see the part of the dev bar that looks like this:

 @Games/play_game.twig

That's information about the template used to render the page, but the first part "Games" is the name of the bundle. Using that information, you can then find that route definition in this file:

 src/AVCMS/Bundles/Games/config/routes.yml

In that file, you would look for this:

 play_game:
   path: /game/{slug}
   defaults: { _controller: Games::GamesController::playGameAction }

This entire process can be sped up with a bit of guesswork. If you're ever modifying something, just ask yourself "What bundle does this probably belong to?" and it'll probably be in the most logical place.

Copy the route

If you haven't already got a file called routes.yml in your webmaster/config directory, you should create it. Otherwise open it up.

Copy the route definition that you found and paste it into your webmaster routes file at the top. Now you can modify the path to what you would like.

Clear the caches

After you've made your changes, clear the caches in the admin panel. Also if you enabled developer mode on your live website, make sure to disable it again.