I have complicated extension with many strings of js-code. So I seaparated each js-functionallity to differente files as extension_functionallity_js.tpl. It was good for OpenCart 2.
In OpenCart 3 I have tried to use TWIG-function include()
In controller of extension I defined array of inc files.
Code: Select all
$data['includes'] = array(
modification(DIR_APPLICATION . 'view/template/extension/module/hpm_product_list_js.twig'),
modification(DIR_APPLICATION . 'view/template/extension/module/hpm_product_list_js__dynamic_content.twig'),
modification(DIR_APPLICATION . 'view/template/extension/module/hpm_product_list_js__attributes.twig'),
modification(DIR_APPLICATION . 'view/template/extension/module/hpm_product_list_js__options.twig')
);
Code: Select all
{% for include_file in includes %}
{{ include(include_file) }}
{% endfor %}
Code: Select all
Fatal error: Uncaught Twig_Error_Loader:
Unable to find template "/home/www/sites/oc-store-3020.loc/public_html/admin/view/template/extension/module/hpm_product_list_js.twig"
(looked into:
/home/www/sites/oc-store-3020.loc/storage/modification/admin/view/template,
/home/www/sites/oc-store-3020.loc/public_html/admin/view/template)
in "extension/module/hpm_product_list_frame.twig" at line 331. in /home/www/sites/oc-store-3020.loc/public_html/system/library/template/Twig/Loader/Filesystem.php on line 215
---
By error description I understood it is not necessary use full path to file. So I tried include only file-names. But result is the same:
Code: Select all
Fatal error: Uncaught Twig_Error_Loader: Unable to find template "hpm_product_list_js.twig" (looked into: /home/www/sites/oc-store-3020.loc/storage/modification/admin/view/template, /home/www/sites/oc-store-3020.loc/public_html/admin/view/template) in "extension/module/hpm_product_list_frame.twig" at line 331. in /home/www/sites/oc-store-3020.loc/public_html/system/library/template/Twig/Loader/Filesystem.php on line 215
Does have anybody any ideas how to resolve this problem to include twig file in twig file?

