Answers.Body: <p>You can use the <code>~</code> (concatenate string) operator to build the URL manually:</p>
  
  <pre><code>{{ url('/discount/discount/view/'~entry.id~'-'~entry.slug) }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-01T13:50:57.997Z
Answers.Text: if i concat the url it doesnt get translated to /korting/id-slug but it will stay /discount/discount/view/id/slug wich u can see isnt pretty.
Answers.UserDisplayName: Terraskye
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-01T14:15:18.873Z
Answers.Text: I wasn't aware that the ```UrlHelper``` class would actually translate action URLs to site routes. Never seen that happen, and can't really pin down where it happens looking through the UrlHelper class. Do you have to do something somewhere to trigger that behaviour? Tried testing out your above code, but PHP choked on the regex in your routes. In any case – I guess just using ```{{ url( 'korting/'~entry.id~'-'~entry.slug) }}``` isn't an option? :)
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-01T13:40:07.177Z
Answers.LastActivityDate: 2015-04-01T13:46:21.217Z
Answers.LastEditDate: 2015-04-01T13:46:21.217Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>I've encounterd a problem with URL creation.</p>
  
  <p>In my plugin I have the following.</p>
  
  <pre><code>public function registerSiteRoutes() {
      return [
          'korting/zoeken' =&gt; array('action' =&gt; '/discount/discount/index'),
          'korting/(?P&lt;id\d+&gt;)-(?P&lt;slug&gt;[a-zA-Z0-9-]+)' =&gt; array('action' =&gt; 'discount/discount/view',),
      ];
  }
  </code></pre>
  
  <p>Now when I'm at the frontend, I use the following to create the URL :</p>
  
  <pre><code>{{ url('/discount/discount/view',{id:entry.id,slug:entry.slug}) }}
  </code></pre>
  
  <p>My plugin gets its data from a solarium document, so its no entry.</p>
  
  <p>I would expect that my URL would become neat like : </p>
  
  <pre><code>/korting/124-test-1
  </code></pre>
  
  <p>but instead I get : </p>
  
  <pre><code>/korting?id=124&amp;slug=test-1
  </code></pre>
  
  <p>This feature is build in by default in the Yii URL manager, but Craft doesn't make use of it. This is resulting in my problem that Craft doesn't have the abbility to make pathed URLs.</p>
  
  <p>Is there any other way for me to do this?</p>
  
Tags: <plugin-development><templating><url>
Title: Pathed URL creation from templated files
ThreadText: # Pathed URL creation from templated files
  
  (Asked by: username_0 on 2015-04-01)
  
  I've encounterd a problem with URL creation.
  
  In my plugin I have the following.
  
  ```
  public function registerSiteRoutes() {
      return [
          'korting/zoeken' => array('action' => '/discount/discount/index'),
          'korting/(?P<id\d+>)-(?P<slug>[a-zA-Z0-9-]+)' => array('action' => 'discount/discount/view',),
      ];
  }
  
  ```
  
  Now when I'm at the frontend, I use the following to create the URL :
  
  ```
  {{ url('/discount/discount/view',{id:entry.id,slug:entry.slug}) }}
  
  ```
  
  My plugin gets its data from a solarium document, so its no entry.
  
  I would expect that my URL would become neat like :
  
  ```
  /korting/124-test-1
  
  ```
  
  but instead I get :
  
  ```
  /korting?id=124&slug=test-1
  
  ```
  
  This feature is build in by default in the Yii URL manager, but Craft doesn't make use of it. This is resulting in my problem that Craft doesn't have the abbility to make pathed URLs.
  
  Is there any other way for me to do this?
  
  **Tags:** plugin-development, templating, url
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-04-01. Score: 2
  
  You can use the `~` (concatenate string) operator to build the URL manually:
  
  ```
  {{ url('/discount/discount/view/'~entry.id~'-'~entry.slug) }}
  
  ```
  
  > **Comments:**
  > **username_0**: if i concat the url it doesnt get translated to /korting/id-slug but it will stay /discount/discount/view/id/slug wich u can see isnt pretty.  
  > **username_1**: I wasn't aware that the ```UrlHelper``` class would actually translate action URLs to site routes. Never seen that happen, and can't really pin down where it happens looking through the UrlHelper class. Do you have to do something somewhere to trigger that behaviour? Tried testing out your above code, but PHP choked on the regex in your routes. In any case – I guess just using ```{{ url( 'korting/'~entry.id~'-'~entry.slug) }}``` isn't an option? :)  
  
  ---
  
  