# Custom, dynamic SEO Url für Plugin

**URL:** <https://forum.shopware.com/t/custom-dynamic-seo-url-fur-plugin/46929>\
**Category:** Programmierung\
**Created:** [14. Juli 2017 um 14:11 UTC](https://forum.shopware.com/t/custom-dynamic-seo-url-fur-plugin/46929 "2017-07-14T14:11:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![langnickel](https://avatars.discourse-cdn.com/v4/letter/l/3ec8ea/32.png) [@langnickel](https://forum.shopware.com/u/langnickel)\
**Post date:** [14. Juli 2017 um 14:11 UTC](https://forum.shopware.com/t/custom-dynamic-seo-url-fur-plugin/46929/1 "2017-07-14T14:11:24Z")

</div>

Ich habe ein Frontend-Controller welcher über …/MyController erreichbar ist.&nbsp;Soweit, so gut. Nun möchte ich aber dass Aufrufe an /MyControlller/{ID}/… auch an die IndexAction meines Controllers gehen, und ich dort {ID} $this-\>Request-\>setPrams(‚myid‘, {ID}) setzen kann, damit mein custom Listing die Produkte sauber filtern kann.

Habs versucht mir irgendwie über das RouterRewrite plugin abzuleiten, aber klappt garnicht&nbsp;:/ Optimal wäre sogar, dass ich MyController durch ein anderes Wort ersetzen kann (z.B. in abhängigkeit der Landessprache, oder nach Konfiguration)

---

<div class="post-metadata">

**Author:** ![langnickel](https://avatars.discourse-cdn.com/v4/letter/l/3ec8ea/32.png) [@langnickel](https://forum.shopware.com/u/langnickel)\
**Post date:** [14. Juli 2017 um 15:59 UTC](https://forum.shopware.com/t/custom-dynamic-seo-url-fur-plugin/46929/2 "2017-07-14T15:59:55Z")

</div>

Ich habe es nun folgendermaßen gelöst (denke aber nicht elegant)

```
    public static function getSubscribedEvents()
    {
        return [
            'Enlight_Controller_Front_RouteShutdown'
            => 'onFrontendRouteShutdown'
            // ...
        ];
    }

    public function onFrontendRouteShutdown(\Enlight_Event_EventArgs $args) {
        $request = $args->getRequest();
        $front = $args->getSubject();
        $response = $front->Response();

        if (!$request->getModuleName() == 'frontend') {
            return;
        }

        $tagIds = [];
        $path = $request->getPathInfo();
        $steps = explode('/', $path);
        $doDispatch = false;
        foreach($steps as $step) {
            if ($doDispatch) {
                // add to ids
                $tagIds[] = trim(strtolower($step));
            }

            if (strtolower($step) == strtolower($this->routerMagicName)) {
                $doDispatch = true;
            }
        }

        if ($doDispatch && count($tagIds) > 0) {
            array_filter($tagIds); ;
            $request->setControllerName('MyController');
            $request->setActionName('index');
            $request->setParam('tagId', strtoupper($tagIds[0]));
        }

    }

```

in meinem Controller in der indexAction dann dementsprechen den den param prüfen
