Search code examples
phptemplatessmartyshopware

How to include template from custom plugin in custom Shopware theme?


I'm trying to include a template from a custom plugin inside a custom theme in Shopware 5.2.

The theme template contains the following line:

{include file="frontend/custom/colorpicker.tpl"}

The plugin template is located in /custom/plugins/PLUGINNAME/Resources/views/frontend/custom/colorpicker.tpl

I get the following error message:

Fatal error: Uncaught SmartyException: Unable to load template snippet 'frontend/custom/colorpicker.tpl' in 'frontend/detail/index.tpl|frontend/plugins/seo/index.tpl' in...

I already tried to add parent to the file path, but with no joy. The error message goes away, but the template is not loaded:

{include file="parent:frontend/custom/colorpicker.tpl"}

Unfortunately I could not find anything in the Shopware documentation, stating whether there is anything special needed to include templates from a Plugin.


Solution

  • Try adding the class variable protected $injectBeforePlugins = true; in your themes Theme.php

    https://developers.shopware.com/designers-guide/smarty/#inheritance-and-plugin-templates