Search code examples
smartyshopware

Using variable on smarty tag name in Shopware


I'm trying to use a variable name to create new snippets, something like this:

{s namespace="frontend/detail/config_variant" name=$variant_group}{/s}

But it doesn't work, it just creates a snippet called $variant_group and I want to get the actual name. I have tried different combinations and none have worked so far. Can this be generated dynamically?

Thanks


Solution

  • This is already mentioned in the official documentation: https://developers.shopware.com/designers-guide/snippets/#using-dynamic-snippets

    {$name = "DetailDataHardness"|cat:$sArticle.attr1}
    {$namespace = "frontend/detail/data"}
    {$sArticle.attr1|snippet:$name:$namespace}