Post by SergeTkach » Tue Sep 01, 2020 8:30 pm

I try to explaine what is the reason.

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')
);
In TWIG-file:

Code: Select all

{% for include_file in includes %} 
 {{ include(include_file) }}
{% endfor %}
This results in the error:

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
I cleaned cache also. It doesn't change nothing.

Does have anybody any ideas how to resolve this problem to include twig file in twig file?
:choke: :choke:

Newbie

Posts

Joined
Thu Oct 03, 2019 7:49 pm

Post by SergeTkach » Tue Sep 01, 2020 8:41 pm

When I asked this question an idea came up.

I will try:

Code: Select all

$data['product_list_js'] = $this->load->view('view/template/extension/module/hpm_product_list_js', $data);

Newbie

Posts

Joined
Thu Oct 03, 2019 7:49 pm

Post by SergeTkach » Tue Sep 01, 2020 8:49 pm

Unfortunately this doesn't work either

Newbie

Posts

Joined
Thu Oct 03, 2019 7:49 pm

User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România
Who is online

Users browsing this forum: No registered users and 17 guests