# Variable/Plugin ansprechen

**URL:** <https://forum.shopware.com/t/variable-plugin-ansprechen/5968>\
**Category:** Shopware 3.5\
**Tags:** programming\
**Created:** [27. Januar 2012 um 20:06 UTC](https://forum.shopware.com/t/variable-plugin-ansprechen/5968 "2012-01-27T20:06:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![albrechtkom](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@albrechtkom](https://forum.shopware.com/u/albrechtkom)\
**Post date:** [27. Januar 2012 um 20:06 UTC](https://forum.shopware.com/t/variable-plugin-ansprechen/5968/1 "2012-01-27T20:06:42Z")

</div>

Hallo, ich wollte die Banner, die auf der Startseite im Shop eingebunden sind - auch auf den Customseiten sowie auf den Artikel-Detailseiten anzeigen lassen. Jetzt habe ich erfahren, dass die Variabe (aus banner.tpl) `{$sBanner.img}` nicht auf den angesprochenen Seiten verfügbar ist / ausgegeben werden kann. Wie kann ich den Inhalt der Variable auf den anderen Seiten verwenden? Wie muss ich vorgehen, sprich wie kann ich eine globale Variable den gleichen Inhalt zuweisen, die ich dann komplett in der Shopware-Template Welt ansprechen bzw. abrufen kann? Dank euch, andré

---

<div class="post-metadata">

**Author:** ![waldicom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/waldicom/32/12881_2.png) [@waldicom](https://forum.shopware.com/u/waldicom)\
**Post date:** [27. Januar 2012 um 21:22 UTC](https://forum.shopware.com/t/variable-plugin-ansprechen/5968/2 "2012-01-27T21:22:48Z")

</div>

Dafür müsste man schauen, wo die Variable $sBanner gesetzt wird: entweder direkt im Plugin oder Suche nach der Variable im “engine” Ordner. Etwa folgendes könnte irgendwo stehen: `$this-\>View()-\>sBanner = Shopware()-\>Modules()-\>Marketing()-\>sBanner($category);` die Funktion sBanner() ist in der Datei core/sMarketing.php definiert.

---

<div class="post-metadata">

**Author:** ![albrechtkom](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@albrechtkom](https://forum.shopware.com/u/albrechtkom)\
**Post date:** [27. Januar 2012 um 22:46 UTC](https://forum.shopware.com/t/variable-plugin-ansprechen/5968/3 "2012-01-27T22:46:33Z")

</div>

Hi! In der core/class/sMarketing.php gibt es folgendes: `public function sBanner($sCategory, $limit=1) { $limit = (int) $limit; $sql = " SELECT \* FROM s\_emarketing\_banners WHERE categoryID=? AND (valid\_from \<= NOW() OR valid\_from='0000-00-00 00:00:00') AND (valid\_to \>= NOW() OR valid\_from='0000-00-00 00:00:00') ORDER BY RAND() LIMIT $limit "; $getBanners = $this-\>sSYSTEM-\>sDB\_CONNECTION-\>GetAll($sql, array($sCategory)); if(empty($getBanners[0])) { return false; } foreach ($getBanners as &$getAffectedBanners) { if(!empty($getAffectedBanners['liveshoppingID'])) { $tmpLive = array('liveshoppingID' =\> $getAffectedBanners['liveshoppingID']); $tmpLive = $this-\>sSYSTEM-\>sMODULES['sArticles']-\>sGetLiveShopping('fix', 0, $tmpLive, true); if(!empty($tmpLive)){ $getAffectedBanners['liveshoppingData'] = $tmpLive['liveshoppingData'][0]; } } if (!empty($getAffectedBanners["img"])){ $getAffectedBanners["img"] = $this-\>sSYSTEM-\>sPathBanner.$getAffectedBanners["img"]; } if (!preg\_match("/http/",$getAffectedBanners["link"]) && !empty($getAffectedBanners["link"])) { $getAffectedBanners["link"] = "http://".$getAffectedBanners["link"]; } } if ($limit == 1 ) { $getBanners = $getBanners[0]; } return $getBanners; }` Die genau gesuchte Variable taucht jedoch nicht darin auf.

---

<div class="post-metadata">

**Author:** ![waldicom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/waldicom/32/12881_2.png) [@waldicom](https://forum.shopware.com/u/waldicom)\
**Post date:** [27. Januar 2012 um 22:57 UTC](https://forum.shopware.com/t/variable-plugin-ansprechen/5968/4 "2012-01-27T22:57:53Z")

</div>

Der Rückgabewert der Funktion wird ja in die Variable $sBanner geschrieben.

---

<div class="post-metadata">

**Author:** ![albrechtkom](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@albrechtkom](https://forum.shopware.com/u/albrechtkom)\
**Post date:** [27. Januar 2012 um 23:03 UTC](https://forum.shopware.com/t/variable-plugin-ansprechen/5968/5 "2012-01-27T23:03:19Z")

</div>

Okay, macht Sinn. In der engine/Shopware/Controllers/Frontend/index.php taucht genau deine Zeile auf: `public function indexAction() { $this-\>View()-\>loadTemplate('frontend/home/index.tpl'); $category = Shopware()-\>Shop()-\>get('parentID'); $this-\>View()-\>sCharts = Shopware()-\>Modules()-\>Articles()-\>sGetArticleCharts(); $this-\>View()-\>sCategoryContent = Shopware()-\>Modules()-\>Categories()-\>sGetCategoryContent($category); $this-\>View()-\>sOffers = Shopware()-\>Modules()-\>Articles()-\>sGetPromotions($category); $this-\>View()-\>sLiveShopping = $this-\>getLiveShopping(); $this-\>View()-\>sBanner = Shopware()-\>Modules()-\>Marketing()-\>sBanner($category); $this-\>View()-\>sBlog = $this-\>getBlog(); if($this-\>Request()-\>getPathInfo()!='/') { $this-\>Response()-\>setHttpResponseCode(404); } }` aber was sagt mir das ganze jetzt? Hilft es überhaupt weiter?

---

<div class="post-metadata">

**Author:** ![waldicom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/waldicom/32/12881_2.png) [@waldicom](https://forum.shopware.com/u/waldicom)\
**Post date:** [27. Januar 2012 um 23:19 UTC](https://forum.shopware.com/t/variable-plugin-ansprechen/5968/6 "2012-01-27T23:19:24Z")

</div>

Den Aufruf dieser Methode könnte man in einem eigenen Plugin benutzen, im die Variable sBanner auf allen/bestimmten Seiten verfügbar zu machen.
