Hey guys,
i was wondering if it's possible (and how) to include a .tpl file in another.
For example, I want to create an extension that uses a single layout html code that just changes position in e.g. product.tpl file (like above price, below image, below action buttons etc. but keeps the same layout). I've tried "include ('url'), i've tried '$this->load->view('extension/path'), but still nothing showed up.
What i want to achieve is not to repeat the same code again and again in OCMOD .xml file.
I've seen a similar function in oc 3.x.x, journal 3 that does the same with "{% include "journal3/template/journal3/product_card.twig" %}".
I hope i made myself clear for that.
Thank you in advance.
<?php include 'journal3/template/journal3/product_card.tpl' ; ?>
Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer
Well, Journal3 is an example on how NOT to do it.
There are different ways to change the order of the DIVs in a given TPL or TWIG file, or to include more data in it, such as by overriding the template files in your own web theme.
Don't use includes in a template file. Rather, define a new controller and template and then use something like this in the main controller:
And the new controller would contain something like this:
And there would a new sub-template at 'extension/new.tpl' (OC2.x) or 'extension/new.twig' (OC 3.x)
There are different ways to change the order of the DIVs in a given TPL or TWIG file, or to include more data in it, such as by overriding the template files in your own web theme.
Don't use includes in a template file. Rather, define a new controller and template and then use something like this in the main controller:
Code: Select all
$data['new'] = $this->load->controller('extension/new');
Code: Select all
return $this->load->view('extension/new', $data);
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Who is online
Users browsing this forum: No registered users and 26 guests