- Posts: 68
COMMUNITY FORUM
Question about contact form/ajax?
- web_dev
-
Topic Author
- Offline
- Senior Member
Less
More
10 years 9 months ago #130629
by web_dev
Question about contact form/ajax? was created by web_dev
Hi,
i have a list with persons, every person is a k2 element and has own extrafield for email adress. In this k2 template i created in item.php a small contact form with ajax, this form has also in the same folder ajax_form_send.php file, my question is, how can i get in this file email adress from this user because if someone do a request then he/she should receive email message?
i have a list with persons, every person is a k2 element and has own extrafield for email adress. In this k2 template i created in item.php a small contact form with ajax, this form has also in the same folder ajax_form_send.php file, my question is, how can i get in this file email adress from this user because if someone do a request then he/she should receive email message?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 9 months ago #130630
by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Question about contact form/ajax?
Ok you can do this two ways.
One way is to get the email from the regular Joomla! user.
Or you can use an extrafield to be filled alongside with the item.
One way is to get the email from the regular Joomla! user.
Or you can use an extrafield to be filled alongside with the item.
Please Log in or Create an account to join the conversation.
- web_dev
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 68
10 years 9 months ago #130631
by web_dev
Replied by web_dev on topic Re: Question about contact form/ajax?
Which way can you recommend? How can i get right email in ajax file?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 9 months ago #130632
by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Question about contact form/ajax?
If the AJAX file is within the K2 template and you are using Joomla!'s API to include it I recommend getting the Joomla! user's email.
Please Log in or Create an account to join the conversation.
- web_dev
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 68
10 years 9 months ago #130633
by web_dev
Replied by web_dev on topic Re: Question about contact form/ajax?
Ma ajax file is in my k2 template for this section (in overrides), can you tell me please how can i load here joomla framework and k2 settings? I mean what's of code needed?
Thanke you in advance.
Thanke you in advance.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 9 months ago #130634
by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Question about contact form/ajax?
You can use this to load the contact form:
$this->item=$item;
echo $this->loadTemplate('YOURTEMPLATE');
Please Log in or Create an account to join the conversation.
- web_dev
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 68
10 years 9 months ago - 10 years 9 months ago #130635
by web_dev
Replied by web_dev on topic Re: Question about contact form/ajax?
Sorry, but my last question, i need only to add this in my ajax file and i will can get normaly extrafield data?
I see now after inserting this rows error message:
Fatal error: Using $this when not in object context in PATH\form_ajax.php on line 11
I see now after inserting this rows error message:
Fatal error: Using $this when not in object context in PATH\form_ajax.php on line 11
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
10 years 9 months ago #130636
by Lefteris
Replied by Lefteris on topic Re: Question about contact form/ajax?
@Mirko
This is a bad practice. Do not add custom files inside the CMS. A custom file is not aware of the Joomla! framework. This means that you will have implement most things from scratch. This also means that you need to pay more attention on the security part. Instead doing that you can write a very basic, simple component to handle the ajax task of sending an email. You can take a read at docs.joomla.org/J3.x:Developing_a_MVC_Component/Developing_a_Basic_Component to see how you can create a really simple component.
This is a bad practice. Do not add custom files inside the CMS. A custom file is not aware of the Joomla! framework. This means that you will have implement most things from scratch. This also means that you need to pay more attention on the security part. Instead doing that you can write a very basic, simple component to handle the ajax task of sending an email. You can take a read at docs.joomla.org/J3.x:Developing_a_MVC_Component/Developing_a_Basic_Component to see how you can create a really simple component.
Please Log in or Create an account to join the conversation.
- web_dev
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 68
10 years 9 months ago #130637
by web_dev
Replied by web_dev on topic Re: Question about contact form/ajax?
yes, but i can not implement any other component in my k2 page, right? Can you please if possible give me reply for above question?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 9 months ago #130638
by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Question about contact form/ajax?
You can also implement a K2 plugin, or you can search for an extension at the JED or getk2.org/extend
Please Log in or Create an account to join the conversation.