<?php
$email = JRequest::getVar('Email', '', 'post');
$name = JRequest::getVar('CognomeNome', '', 'post');
$MyForm->formrow->redirecturl = JURI::base()."index.php?option=com_jnews&act=subscribe&listid=15&receive_html=1&email=$email&name=$name&passwordA=xxxx&redirectlink=http://www.tregima.it/email-inviata-home.html";
?>
Now with Joomla 1.7.2, chornoforms v4.0rc2.0 and JNews v 7.4.2 does not work anymore integration, ie when one is not redirected to fill out the form and the name and email address are not included in my list of newsletters
I came in the ChronoForms component, then edit wizard-event, I added custom code and I entered the same code.
What's wrong?
I searched the forums and I saw someone talking about using Curl, I tried looking but I have not understood anything.
Who can help me?
thanks
stefano
In CFv4 you can use the ReDirect URL action to build the URL and the ReDirect User to refirect the user to the URL. This would replicate the code here.
The CURL action would allow you to send the data to the JNews component 'behind the scenes' without sending the User there.
The configuration for both the cURL and ReDirect URL actions is very similar.
Bob
I put this code in CustomCode:
<?php
$email = JRequest::getVar('Email', '', 'post');
$name = JRequest::getVar('CognomeNome', '', 'post');
$MyForm->formrow->redirecturl = JURI::base()."index.php?option=com_jnews&act=subscribe&listid=15&receive_html=1&email=$email&name=$name&passwordA=xxxx";
?>
and then I add the form field and put the Redirect User ULR where the user must be redirected
But the problem is that no data is recorded in JNews 😟
In CFv4 you can use the ReDirect URL action to build the URL and the ReDirect User to refirect the user to the URL. This would replicate the code here.
The CURL action would allow you to send the data to the JNews component 'behind the scenes' without sending the User there.
The configuration for both the cURL and ReDirect URL actions is very similar.
Bob
Here's the Help tab from the CURL [GH] action - not all these features are in the standard action but it should help:
This is an advanced cURL Action for ChronoForms v4 on Joomla! 1.5 & 1.6. It has the same basic functions as the standard Email Action but adds more features and uses slightly different code in the configuration.
The General tab
Enter the URL that you want to send the data to in the Target URL box. This must either be a valid URL (complete with the http:// or https:// prefix). If you leave the box empty it will default to the current site http://frances/Joomla1.7a/administrator/ Do not include any part of the URL after a '?'; add the query values to the Params/Fields map box instead e.g. option=com_acymailing.
The Params/Fields map is the main configuration box. Enter each data item that you want to send in this box using one line for each item. Each item takes the form of curl_parameter=some_value. You can use values from the form results by using the 'curly bracket' syntax {input_name}. Note: to set an empty parameter use the value NULL; lines with no value will be ignored.
For advanced use only: You can also set custom cURL options in the Params/Fields map box. They must come after the cURL parameters and after a line with just ##CURLOPTS## on it. Entries take the form of CURLOPT=value e.g. CURLOPT_URL=http://example.com
Here's an example of a set of entries:
banana=name
lettuce=email
apple={name}
beetroot={email}
##CURLOPTS##
CURLOPT_URL=http://example.com
CURLOPT_TIMEOUT=60
The Header in Response option will return the full header details on the cURL submission. Leave this set to 'No' unless you are de-bugging or know that you need the information as it may well show the whole of the responding web page!!
Bob
pardon my ignorance, but could you give me an example because I did not understand anything of what I should do.
thank you very much
stefano
Step 1: Exactly what information do you need to pass to JNews?
Bob
Hi Stefano,
Step 1: Exactly what information do you need to pass to JNews?
Bob
Name and email address, and the two form fields are name1 and email
In that case what you need in the cURL [GH] code box is
name={name1}
email={email}
But I'm pretty certain that isn't the full list of parameters.
Bob
Then after the redirect has to do and I have to use the Redirect URL field or Redirect User?
thanks
I tried to follow your written isctruzioni here: http://chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=9&t=20582&p=63794&hilit=jnews # p63103
But it must be changed because the version of curl do not see the screen of your screenshots
You need to look at the JNews documentation and work out exactly what data needs to be sent.
The cURL setting are slightly different in the CURL [GH] action in CFv4 - the dynamic values go into the main box using curly brackets as I showed you in my last post.
Bob
I also asked for help to JNews forums and they told me this thing:
Hi Stefano,
Just please ask if having these params it should be working:
option=com_jnews
act=subscribe
name={CognomeNome}
email={email}
passwordA=xxxxxxx
fromSubscribe=1
listid=15
receive_html=1
or there are still things to do.
Kindly say/port in the forum that you have already provided the correct params but still after the subsmission of the form the subscription to jNews is still not called.
Kind Regards,
Mary
Could you help me? thanks
How does this differ from what you have in the cURL [GH] code box?
Bob
And I can not understand the "voice" Where can I find that you used?
Is debug still enabled? That stops the redirection and displays the link instead.
What 'voice'? I don't understand that question.
Bob
[attachment=0]Mobili TreGima - Amministrazione.jpg[/attachment]
I have to keep the two items in the Curl? or just the one you've entered?
I enabled debugging now
The Custom Code action is used to set the variables needed by the cURL action.
Bob
[attachment=0]dsfsdfsa.jpg[/attachment]
It's a plain Custom Code action from the main 'Core Actions' group - with a label 'Set cURL data'.
Bob
I tried to do the same thing with other forms, but does not work .... no "record" data JNews
You can see where I went wrong?
thanks
I do not understand why it does not work with other forms .... I just copied and pasted the same thing that works in the form
What do you want me to look at? I've just checked and the HomePage form is working correctly.
Bob
The Form HTML for the Cucine form was broken
<td><input type="text" title="Inserire un indirizzo Email corretto" class="validate['required','Email'] name="Email" />*</td>
There is a quote missing after the class attribute.When that is fixed the form works OK.
Bob
Here's a form tested in Joomla! 1.7 with CFv4 RC3.0 and JNews 7.4.0
I only have time to post the file now; I'll add some more notes later.
Later:
The form uses a Custom Code element for the checkboxes because JNews uses indexed array names like subscribed[1] that ChronoForms cannot easily replicate. The code for the Custom element is
<input type="checkbox" name="subscribed[1]" id="subscribed_1" title="" value="1" checked="checked" class="" />
<label for="subscribed_1">List 1</label>
<input type="checkbox" name="subscribed[2]" id="subscribed_2" title="" value="2" class="" />
<label for="subscribed_2">List 2</label>
This is copied from a ChronoForms Checkbox group apart from the [1] and [2].There are two other standard ChronoForms text inputs named 'name' and 'email'.
In the ON Submit event there is a Custom Code action that is used to add the 'fixed' values into the form results array so that they are available to the following cURL action*. The code here is
<?php
$form->data['sub_list_id'] = array(1 => 17, 2 => 18);
$form->data['acc_level'] = array(1 => 0, 2 => 0);
$form->data['option'] = 'com_jnews';
$form->data['act'] = 'subscribe';
$form->data['receive_html'] = 1;
$form->data['redirectlink'] = '';
$form->data['listname'] = 1;
$form->data['passwordA'] = 'f4DITIdzhuZag';
$form->data['fromSubscribe'] = 1;
?>
You will need to change the password and probably some other values depending on the set up of your site and form.Lastly there is a cURL action with a target url of the site root e.g. http://www.my_domain.com/index.php and a Params/Field map like this
option=option
act=act
name=name
email=email
subscribed=subscribed
sub_list_id=sub_list_id
acc_level=acc_level
redirectlink=redirectlink
listname=listname
passwordA=passwordA
fromSubscribe=fromSubscribe
Each of these lines has a JNews paramter name before the = sign and a name from the ChronoForms $form->data array after the = sign. In this case I've set them up so that both names are the same, they don't need to be but it helps to be consistent. This form is a replica of the form from the JNews module. There are various other ways that you could construct a form - automatically subscribing to a single list for example; or offering HTML/Plain text as a check box. You can adjust the form to meet your needs.
This form submits using cURL after the main form is submitted whereas the JNews form uses Ajax. You could change the form easily to use an HHTP request before submission; or with more work to use Ajax.
Bob
*This is because the standard cURL action only accepts 'dynamic' values from the form data. If you use my custom cURL [GH] action which accpets both 'static' and 'dynamic' then you can combine most of the code from the Custom Code action into the cURL [GH] action.