Answers.Body: <p>To quote @Brandon from <a href="https://plus.google.com/116110705947365375372/posts/awJsEZKn2kn">here</a>:</p>
  
  <blockquote>
    <p>Yep you just need to include a $variables argument in your controller
    function, typeset to an array:</p>
  
  <pre><code>public function actionArchive(array $variables = array())
  {
      $variables['year'] ...
  }
  </code></pre>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-16T09:35:01.367Z
Answers.Text: Gosh, why not write this in the docs? Craft is a bucket of unobvious solutions...
Answers.UserDisplayName: Stalinko
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-16T14:02:56.483Z
Answers.Text: @Stalinko haha! That is fair. Craft 3 is much nicer though ;)
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-17T08:20:08.840Z
Answers.LastActivityDate: 2014-06-17T08:20:08.840Z
Answers.UserDisplayName: Andris Sevcenko
Body: <p>I'm writing a plugin that uses the registerSiteRoutes hook to create some new routes, and passes those routes to some controllers. In these routes, I have a few pieces of the URL that I'm capturing as named subpatterns. I'm curious how I handle these named variables in the controller that receives them.</p>
  
Tags: <plugin-development><routes><controller><hook>
Title: How do I handle named route variables passed to a controller?
ThreadText: # How do I handle named route variables passed to a controller?
  
  (Asked by: username_0 on 2014-06-17)
  
  I'm writing a plugin that uses the registerSiteRoutes hook to create some new routes, and passes those routes to some controllers. In these routes, I have a few pieces of the URL that I'm capturing as named subpatterns. I'm curious how I handle these named variables in the controller that receives them.
  
  **Tags:** plugin-development, routes, controller, hook
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-06-17. Score: 7 | Accepted answer
  
  To quote @username_3 from [here](https://plus.google.com/116110705947365375372/posts/awJsEZKn2kn):
  
  > Yep you just need to include a $variables argument in your controller
  > function, typeset to an array:
  >
  > ```
  > public function actionArchive(array $variables = array())
  > {
  >     $variables['year'] ...
  > }
  >
  > ```
  
  > **Comments:**
  > **username_2**: Gosh, why not write this in the docs? Craft is a bucket of unobvious solutions...  
  > **username_3**: @username_2 haha! That is fair. Craft 3 is much nicer though ;)  
  
  ---
  
  