# CMS Blöcke in TWIG Template nutzen?

**URL:** <https://forum.shopware.com/t/cms-bloecke-in-twig-template-nutzen/94865>\
**Category:** Programmierung\
**Created:** [17. Juni 2022 um 08:39 UTC](https://forum.shopware.com/t/cms-bloecke-in-twig-template-nutzen/94865 "2022-06-17T08:39:53Z")\
**Posts on this page:** 1\
**Showing post:** 21

<div class="post-metadata">

**Author:** ![zlep](https://avatars.discourse-cdn.com/v4/letter/z/9de0a6/32.png) [@zlep](https://forum.shopware.com/u/zlep)\
**Post date:** [6. Juli 2022 um 08:35 UTC](https://forum.shopware.com/t/cms-bloecke-in-twig-template-nutzen/94865/21 "2022-07-06T08:35:14Z")

</div>

@abdullah  
Du scheinst recht zu haben. Ich verwende nun die TagId und damit scheint es zu funktionieren.

Hier mal meine Lösung. Bin mir noch nicht ganz sicher, ob das wirklich am besten so gelöst ist:

Als Service benötigt man noch das tag.repository

```auto
<argument type="service" id="tag.repository"/>

```

Danach hole ich die TagId anhand des Tag Namen:

```auto
$tagName = new Criteria();
$tagName->addFilter(new EqualsFilter('tag.name', 'meinTag'));
$tagId = $this->tagRepository->searchIds($tagName, $event->getContext())->firstId();

```

Anhand der TagId hole ich letztlich die Produkte:

```auto
$criteria = new Criteria();
$criteria->addAssociation('tagIds');
$criteria->addFilter(new EqualsFilter('tagIds', $tagId));

$products = $this->salesChannelRepository->search($criteria, $event->getSalesChannelContext())->getEntities();

```

---

_[View the full topic](https://forum.shopware.com/t/cms-bloecke-in-twig-template-nutzen/94865)._
