Answers.Body: <p>Old question, but might still might help somebody...</p>
  <p>What about a route in <code>config/routes.php</code>?</p>
  <pre><code>config/routes.php
  
  ...
  return [
    'artist/&lt;artistEntrySlug:{slug}&gt;/news' =&gt; ['template' =&gt; '_pages/artists/news.twig'],
  ];
  </code></pre>
  <p>In your <code>news.twig</code> you should be able to fetch the artist details by:</p>
  <pre><code>{% set artistEntry = craft.entries().slug(artistEntrySlug).one() %}
  </code></pre>
  <p>See Craft5 docs on advanced routing:
  <a href="https://craftcms.com/docs/5.x/system/routing.html#advanced-routing-with-url-rules" rel="nofollow noreferrer">https://craftcms.com/docs/5.x/system/routing.html#advanced-routing-with-url-rules</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-11-11T09:50:00.680Z
Answers.LastActivityDate: 2024-11-11T09:50:00.680Z
Answers.UserDisplayName: geschud
Answers.Body: <p>You can achieve this by <a href="https://craftcms.com/docs/3.x/extend/module-guide.html" rel="nofollow noreferrer">writing a module</a> and using the <code>UrlManager::EVENT_REGISTER_SITE_URL_RULES</code> event.</p>
  <p>Basic example:</p>
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  use craft\elements\Entry;
  use craft\events\RegisterUrlRulesEvent;
  use craft\web\UrlManager;
  use yii\base\Event;
  
  class CustomModule
  {
      public function init()
      {
          parent::init();
  
          Event::on(
              UrlManager::class,
              UrlManager::EVENT_REGISTER_SITE_URL_RULES,
              static function (RegisterUrlRulesEvent $event) {
                  $artistEntries = Entry::find()-&gt;section('artists')-&gt;all();
  
                  foreach ($artistEntries as $artistEntry) {
                      $event-&gt;rules[$artistEntry-&gt;uri] = ['template' =&gt; '_pages/artists/news'];
                  }
              }
          );
      }
  }
  </code></pre>
  <p>Then, in the _<em>pages/artists/news.twig</em> template, you'll need to extract the artist's slug from <code>craft.app.request.url</code> and use it to get the Entry corresponding to your artist.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-25T18:29:19.930Z
Answers.Text: Thanks very much!
Answers.UserDisplayName: Matthias
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-14T17:35:23.660Z
Answers.LastActivityDate: 2020-09-14T17:35:23.660Z
Answers.UserDisplayName: nstCactus
Body: <p>Is it possible to have a URI like this: /artist/{slug}/news
  to create an overview of all news articles of this particular artist?</p>
  <p>I tried to set it up with Routes and with a section Entry URI, but I get a 404</p>
  
Tags: <sections><routes>
Title: URI with multiple URL formats (after slug)
ThreadText: # URI with multiple URL formats (after slug)
  
  (Asked by: username_0 on 2020-09-12)
  
  Is it possible to have a URI like this: /artist/{slug}/news
  to create an overview of all news articles of this particular artist?
  
  I tried to set it up with Routes and with a section Entry URI, but I get a 404
  
  **Tags:** sections, routes
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2024-11-11. Score: 1
  
  Old question, but might still might help somebody...
  
  What about a route in `config/routes.php`?
  
  ```
  config/routes.php
  
  ...
  return [
    'artist/<artistEntrySlug:{slug}>/news' => ['template' => '_pages/artists/news.twig'],
  ];
  
  ```
  
  In your `news.twig` you should be able to fetch the artist details by:
  
  ```
  {% set artistEntry = craft.entries().slug(artistEntrySlug).one() %}
  
  ```
  
  See Craft5 docs on advanced routing:
  <https://craftcms.com/docs/5.x/system/routing.html#advanced-routing-with-url-rules>
  
  
  ---
  
  ### Answer by username_2 on 2020-09-14. Score: 1
  
  You can achieve this by [writing a module](https://craftcms.com/docs/3.x/extend/module-guide.html) and using the `UrlManager::EVENT_REGISTER_SITE_URL_RULES` event.
  
  Basic example:
  
  ```php
  <?php
  
  use craft\elements\Entry;
  use craft\events\RegisterUrlRulesEvent;
  use craft\web\UrlManager;
  use yii\base\Event;
  
  class CustomModule
  {
      public function init()
      {
          parent::init();
  
          Event::on(
              UrlManager::class,
              UrlManager::EVENT_REGISTER_SITE_URL_RULES,
              static function (RegisterUrlRulesEvent $event) {
                  $artistEntries = Entry::find()->section('artists')->all();
  
                  foreach ($artistEntries as $artistEntry) {
                      $event->rules[$artistEntry->uri] = ['template' => '_pages/artists/news'];
                  }
              }
          );
      }
  }
  
  ```
  
  Then, in the \_*pages/artists/news.twig* template, you'll need to extract the artist's slug from `craft.app.request.url` and use it to get the Entry corresponding to your artist.
  
  > **Comments:**
  > **username_0**: Thanks very much!  
  
  ---
  
  