Post by ChristmasJones » Wed Oct 20, 2021 6:32 pm

Hello

Could someone help me understand the relationship between the php control files and the twig template files, can you and how do you pass variables from the twig files to the php file to allow the php file to process the data in the variable.

I am trying to write an input box to go into the footer to collect email address for newsletter signup. I have got the input box and button in the foot via editing the footer.twig file, but I cannot get the variable data to pass to the php file for it to process the variable and submit the email address into the database.

if this isn’t possible them what is the process of an account registration where there must be a process to check the account email address as the system reports if the email address already exists

thanks in advanced for all your help


Posts

Joined
Wed Oct 06, 2021 5:53 pm

Post by OSWorX » Wed Oct 20, 2021 7:18 pm

ChristmasJones wrote:
Wed Oct 20, 2021 6:32 pm
Hello

Could someone help me understand the relationship between the php control files and the twig template files, can you and how do you pass variables from the twig files to the php file to allow the php file to process the data in the variable.

I am trying to write an input box to go into the footer to collect email address for newsletter signup. I have got the input box and button in the foot via editing the footer.twig file, but I cannot get the variable data to pass to the php file for it to process the variable and submit the email address into the database.

if this isn’t possible them what is the process of an account registration where there must be a process to check the account email address as the system reports if the email address already exists

thanks in advanced for all your help
Done by javascript.
Call with it the controller where you can handle the values (e.g. storing into the database).

What you are trying to achieve, is what you get with that: https://osworx.net/Newsletter-Pro-30

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by straightlight » Wed Oct 20, 2021 9:22 pm

ChristmasJones wrote:
Wed Oct 20, 2021 6:32 pm
Hello

Could someone help me understand the relationship between the php control files and the twig template files, can you and how do you pass variables from the twig files to the php file to allow the php file to process the data in the variable.

I am trying to write an input box to go into the footer to collect email address for newsletter signup. I have got the input box and button in the foot via editing the footer.twig file, but I cannot get the variable data to pass to the php file for it to process the variable and submit the email address into the database.

if this isn’t possible them what is the process of an account registration where there must be a process to check the account email address as the system reports if the email address already exists

thanks in advanced for all your help
OC version. Could be achieved by using an Event Trigger: https://github.com/opencart/opencart/wiki/Events-System . In addition, you could refer to the catalog/controller/extension/advertise/google.php file on how to do that with the footer. :)

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by thekrotek » Wed Oct 20, 2021 11:18 pm

Template engine doesn't matter here at all. You either add a form to template and submit the data using old-school way or use AJAX to pass the data and display the feedback dynamically. This task requires some very basic coding skills.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by OSWorX » Wed Oct 20, 2021 11:50 pm

thekrotek wrote:
Wed Oct 20, 2021 11:18 pm
Template engine doesn't matter here at all. You either add a form to template and submit the data using old-school way or use AJAX to pass the data and display the feedback dynamically. This task requires some very basic coding skills.
That's what I already wrote above.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by ChristmasJones » Thu Oct 21, 2021 2:22 am

Thank you for all your responses.

OSWorX, I took a look at your extension with interest, but as I’m just starting up and trying to get the website up and running with as little cost as possible (money needs to be spent on machinery). I don’t really have the spare money for your extension. I appreciate that it will pay for itself in the long run but until I earn some money, what I have needs to be spent elsewhere

Thekrotek could you explain a bit more about using an AJAX script to get this to work as that sounds like it is what I’m looking for. Would the AJAX code be based in the TWIG file or would it be called from within the TWIG file?


Posts

Joined
Wed Oct 06, 2021 5:53 pm

Post by straightlight » Thu Oct 21, 2021 2:34 am

ChristmasJones wrote:
Thu Oct 21, 2021 2:22 am
Thank you for all your responses.

OSWorX, I took a look at your extension with interest, but as I’m just starting up and trying to get the website up and running with as little cost as possible (money needs to be spent on machinery). I don’t really have the spare money for your extension. I appreciate that it will pay for itself in the long run but until I earn some money, what I have needs to be spent elsewhere

Thekrotek could you explain a bit more about using an AJAX script to get this to work as that sounds like it is what I’m looking for. Would the AJAX code be based in the TWIG file or would it be called from within the TWIG file?
A free solution to develop the idea has already been provided on my previous reply.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by thekrotek » Thu Oct 21, 2021 2:36 am

ChristmasJones wrote:
Thu Oct 21, 2021 2:22 am
Thekrotek could you explain a bit more about using an AJAX script to get this to work as that sounds like it is what I’m looking for. Would the AJAX code be based in the TWIG file or would it be called from within the TWIG file?
I'm sorry, but your questions are not related to OpenCart at all. They are related to the basics of coding. Please, use resources like StackOverflow and JQuery tutorials to learn about AJAX.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by paulfeakins » Thu Oct 21, 2021 5:42 pm

ChristmasJones wrote:
Wed Oct 20, 2021 6:32 pm
Could someone help me understand the relationship between the php control files and the twig template files, can you and how do you pass variables from the twig files to the php file to allow the php file to process the data in the variable.
You should look up the MVC design pattern.

But in very simple terms, it is the controller than runs and the twig is included at the bottom with a $data variable passed to it.

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

Post by straightlight » Thu Oct 21, 2021 10:11 pm

In each desired controllers, you could look for each lines that contains:

Code: Select all

$this->load->view

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 264 guests