Post by KanKan2022 » Thu Aug 18, 2022 4:58 pm

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

New member

Posts

Joined
Sat Jul 02, 2022 4:36 pm

User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by KanKan2022 » Thu Aug 18, 2022 6:47 pm

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

New member

Posts

Joined
Sat Jul 02, 2022 4:36 pm

Post by KanKan2022 » Thu Aug 18, 2022 6:56 pm

Actually I may have misunderstood your post, I'm going over it again thanks

New member

Posts

Joined
Sat Jul 02, 2022 4:36 pm

Post by paulfeakins » Fri Aug 19, 2022 8:03 pm

KanKan2022 wrote:
Thu Aug 18, 2022 4:58 pm
Is it possible in the controller to return that twig file with changes?
Probably, but why are you doing that? What are you wanting the end result to be?

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom
Who is online

Users browsing this forum: No registered users and 264 guests