Modifying URL's

From AV Scripts Wiki
Jump to: navigation, search

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 YAML 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. Once you have it enabled, 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:


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:


In that file, you would look for this:

   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.

Edit the route

Now you can modify the path of the route to what you would like. Make sure to keep the words or phrases that are within curly braces the same (like "slug" above). They are just variable names.

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.

Optional: Edit the controller

Advanced: If you would like to make the route instead be handled by a different controller action you can edit the 'Games::GamesController::playGameAction' part of the configuration. The first part is the bundle name, the second part is the class name of the controller and the third part is the method in the controller that should be called.