# {if $Controller == 'listing'} funktioniert nicht

**URL:** <https://forum.shopware.com/t/if-controller-listing-funktioniert-nicht/34605>\
**Category:** Programmierung\
**Created:** [19. Februar 2016 um 10:18 UTC](https://forum.shopware.com/t/if-controller-listing-funktioniert-nicht/34605 "2016-02-19T10:18:56Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![sonn](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@sonn](https://forum.shopware.com/u/sonn)\
**Post date:** [19. Februar 2016 um 10:18 UTC](https://forum.shopware.com/t/if-controller-listing-funktioniert-nicht/34605/1 "2016-02-19T10:18:56Z")

</div>

Hallo,

ich möchte gerne den emotion Slider um eine Information ergänzen. Diese Info soll nur im Listing erscheinen. Dafür habe ich folgendes angegeben:

```
{extends file="parent:frontend/listing/product-box/box-emotion.tpl"}

{* Product name *}
{block name='frontend_listing_box_article_name' append}
    {if $Controller == 'listing'}
{$sArticle.swag_attr21|strip_tags|truncate:70}
    {/if}
{/block}

```

Was ist denn falsch?

&nbsp;

Gruß

Patrick

---

<div class="post-metadata">

**Author:** ![dbld](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@dbld](https://forum.shopware.com/u/dbld)\
**Post date:** [19. Februar 2016 um 10:26 UTC](https://forum.shopware.com/t/if-controller-listing-funktioniert-nicht/34605/2 "2016-02-19T10:26:04Z")

</div>

Was genau macht er nicht?&nbsp;

Wird das div dargestellt und ist leer oder wird es gar nicht angezeigt?

---

<div class="post-metadata">

**Author:** ![sonn](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@sonn](https://forum.shopware.com/u/sonn)\
**Post date:** [19. Februar 2016 um 10:27 UTC](https://forum.shopware.com/t/if-controller-listing-funktioniert-nicht/34605/3 "2016-02-19T10:27:35Z")

</div>

Es kommt gar nicht. Ohne der Anweisung zum Controller kommt es, aber halt auch z.B. auf der Startseite und dort wollte ich die Info nicht.

---

<div class="post-metadata">

**Author:** ![dbld](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@dbld](https://forum.shopware.com/u/dbld)\
**Post date:** [19. Februar 2016 um 10:33 UTC](https://forum.shopware.com/t/if-controller-listing-funktioniert-nicht/34605/4 "2016-02-19T10:33:25Z")

</div>

Lass dir mal den wert von $Controller anzeigen. Ich denke der ist hier eher immer emotion als was anderes.

---

<div class="post-metadata">

**Author:** ![sonic](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/sonic/32/25728_2.png) [@sonic](https://forum.shopware.com/u/sonic)\
**Post date:** [19. Februar 2016 um 10:42 UTC](https://forum.shopware.com/t/if-controller-listing-funktioniert-nicht/34605/5 "2016-02-19T10:42:49Z")

</div>

Versuch es mal so, wie auch im Bare der Controller abgefragt wird - mit **{controllerName}**

```
{if {controllerName} == 'listing'} 

 &nbsp;
```

---

<div class="post-metadata">

**Author:** ![sonn](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@sonn](https://forum.shopware.com/u/sonn)\
**Post date:** [19. Februar 2016 um 10:50 UTC](https://forum.shopware.com/t/if-controller-listing-funktioniert-nicht/34605/6 "2016-02-19T10:50:59Z")

</div>

Ging auch nicht.

---

<div class="post-metadata">

**Author:** ![sonn](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@sonn](https://forum.shopware.com/u/sonn)\
**Post date:** [19. Februar 2016 um 11:26 UTC](https://forum.shopware.com/t/if-controller-listing-funktioniert-nicht/34605/7 "2016-02-19T11:26:03Z")

</div>

Jetzt habe ich mal mit

{if $Controller !=&nbsp;‘index’}  
&nbsp;

versucht. Funktioniert teilweise. Im Liveshopping geht es, aber nicht in anderen Elementen.&nbsp;

---

<div class="post-metadata">

**Author:** ![sonic](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/sonic/32/25728_2.png) [@sonic](https://forum.shopware.com/u/sonic)\
**Post date:** [19. Februar 2016 um 11:35 UTC](https://forum.shopware.com/t/if-controller-listing-funktioniert-nicht/34605/8 "2016-02-19T11:35:49Z")

</div>

Lass Dir doch einfach mal den Controllernamen anstelle vom&nbsp;swag\_attr21 ohne If ausgeben. Dann siehst Du doch, wie der passende Name in den verschiedenen Listen ist.  
Und immer schön den Cache leeren.

---

<div class="post-metadata">

**Author:** ![Stephan\_Pohl](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/stephan_pohl/32/10212_2.png) [@Stephan\_Pohl](https://forum.shopware.com/u/Stephan_Pohl)\
**Post date:** [19. Februar 2016 um 11:42 UTC](https://forum.shopware.com/t/if-controller-listing-funktioniert-nicht/34605/9 "2016-02-19T11:42:33Z")

</div>

Hallo @sonn‍,

den Controller-Namen kannst du in Shopware 5 über die Smarty Funktion {controllerName} abfragen:

```
{if {controllerName} === 'home'}
   {* do your home specific stuff here *}
{/if}

```

Dein Code-Beispiel lässt darauf schließen, dass du die Artikel-Box der Einkaufswelten bearbeiten willst. Beachte hierbei dass der Controller-Name der Einkaufswelten immer Emotion ist, egal ob die Einkaufswelt auf der Startseite oder&nbsp;in einer Kategorie einbunden wird.

Viele Grüße,  
Stephan&nbsp; ![Shopware](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/86c57fbace799dd4eb1f1b8a2d3bdc1733f0aea1.png "Shopware")

---

<div class="post-metadata">

**Author:** ![sonn](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@sonn](https://forum.shopware.com/u/sonn)\
**Post date:** [19. Februar 2016 um 12:18 UTC](https://forum.shopware.com/t/if-controller-listing-funktioniert-nicht/34605/10 "2016-02-19T12:18:07Z")

</div>

So ganz kapiere ich es noch nicht.

Also, der Controller ist dann emotion. Und wenn ich dann das Element nur im Listing anzeigen lassen möchte, was mache ich dann? Auf der Startseite ist auch eine Einkaufswelt mit Slidern.

---

<div class="post-metadata">

**Author:** ![EikeBrandtWarneke](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@EikeBrandtWarneke](https://forum.shopware.com/u/EikeBrandtWarneke)\
**Post date:** [19. Februar 2016 um 12:29 UTC](https://forum.shopware.com/t/if-controller-listing-funktioniert-nicht/34605/11 "2016-02-19T12:29:50Z")

</div>

Einkaufswelten werden immer über einen eigenen request geladen. Der controller dafür ist immer emotion. Du kannst im Shopware standard innerhalb der Einkaufswelt nicht erkennen auf welcher Seite sie geladen wird.

Viele Grüße

---

<div class="post-metadata">

**Author:** ![sonn](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@sonn](https://forum.shopware.com/u/sonn)\
**Post date:** [19. Februar 2016 um 12:32 UTC](https://forum.shopware.com/t/if-controller-listing-funktioniert-nicht/34605/12 "2016-02-19T12:32:48Z")

</div>

ok, jetzt hab ich es kapiert.

Danke.
