Hello,
I have a controller file which has the following line which returns a twig file:
return $this->load->view('mail/'.$this->moduleName, $this->data);
In the twig file that is returned, it contains this piece of code:
<a style="text-decoration:none;color:#00B7FF;display:block;padding:0;margin:0 0 5px 0;font-size:14px;" href="{{ href[product.product_id] }}" target="_blank">
{{ product.name }}
</a>
Is it possible in the controller to return that twig file with changes? For example - change the color from #00B7FF to #000000 or for example change {{ product.name }} to blank ({{ product.name }} = "")?
I've tried the standard PHP str_replace but it doesn't work
Thanks
Yes, it can be done via event handlers, see this forum post for details.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Thanks for the info. I think in my application I wouldn't be able to do it as an event install, because in the controller I would like to change the twig depending on the different shortcodes used. Is there a way for me to dynamically create a twig in the controller to return? I tried using the entire twig file as a php variable and using str_replace but again that didn't work. At the moment what I have done is create a whole lot of different twig files and call the appropriate one through code in the controller, but I was wondering if there was a more elegant way of doing it.
Thanks
Thanks
Probably, but why are you doing that? What are you wanting the end result to be?KanKan2022 wrote: ↑Thu Aug 18, 2022 4:58 pmIs it possible in the controller to return that twig file with changes?
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
Who is online
Users browsing this forum: No registered users and 256 guests