Forums

Dynamic Subject and cf_id in Subject

pnut 27 Jan, 2010
Hello all,

I have been browsing this wonderful helpful forum for a few days now. A client whom uses ChronoForms on his website wants to receive the forms with a number in the email and in the email subject.

I have chosen to use the cf_id that ChronoForms generates as the integer to become a serial number. Important to know that cf_id is not a field in the form itself. I know how to get that in a subject line. This is the cf_id generated by CF. Just a bit different.

Partially I have succeeded based on answers found in the forum.

1. Getting the cf_id to show up in the email template is done with the help of:
<?php echo "Number: ".$MyForm->tablerow["jos_chronoforms_nlr_onlinejudgeregistration"]->cf_id;?>


That part is working.

2. Now the administrator of the site wants that same cf_id to show up in the subject of the email. I have found partially how I can get the solution working, but no matter what I do, the cf_id is not showing in the subject.

The code I am using as a basis is derived from this topic here: http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=16006&p=41295&hilit=subject+cd+id#p41295 :

<?php
$id = $MyForm->tablerow["jos_chronoforms_nlr_onlinejudgeregistration"]->cf_id;
$subject = 'some text '.$id;
JRequest::setVar('subject', $subject);
?>


But $id is not working. I have tried numerous alternatives, it simply shows "some text" as subject, but is skipping the cf_id. So most of it is working, it is in the OnSubmit Before Email code, that all seems to be ok.

If there is anyone out there who could help me with that last part, get the cf_id show up in the subject. I am close, but not yet there.

Any help is appreciated.

Hope to hear from you soon.

With best regards,

Piet Nutbey
GreyHead 27 Jan, 2010
Hi pnut,

The normal workflow is

Before Email -> Email -> After Email -> DB save

You need to change the sequence so that the DB save is before the email that is when the cf_id is generated. There's a setting on the DB Connection tab.

Bob
pnut 27 Jan, 2010
Hello Bob,

Thank you for the reply.

That order is already correct. The cf_id in the email template (and the email received) is working. I had changed the settings and the DB Connection is saving data before email is sent.

So again, Nº 1 in my post is working 100%. cf_id in the email template and received email

It is Nº2 I cannot seem to get working, cf_id in email subject - must be something wrong in my code? The "some text" part comes through, but not the cf_id.

<?php
$id = $MyForm->tablerow["jos_chronoforms_nlr_onlinejudgeregistration"]->cf_id;
$subject = 'some text '.$id;
JRequest::setVar('subject', $subject);
?>
GreyHead 27 Jan, 2010
Hi pnut,

That should work OK provided that you have a Dynamic Subject with subject in the box.

If it doesn't then it may still be a work-flow problem, I'd need to go back and look at the code.

Bob
pnut 27 Jan, 2010
Hi Bob,

That should work OK provided that you have a Dynamic Subject with subject in the box.



Yes, I have that.

I receive the email and proper subject (except missing cf_id)
$subject = 'some text '.$id;


But only receiving "some text" in the subject

So the code is working, except for the cf_id. Again, important to know, in the email body, the cf_id is also being called and is showing the correct number. So it seems the cf_id and the work-flow are correct, if cf_id is showing up properly in the body. Just not in the subject.
pnut 28 Jan, 2010
Hello Bob,

I can see you are a busy man with all the help and answers you give on the forum.

Do you have any idea what might be happening here? As mentioned, the cf_id in the form itself is being called correct, but not in the subject. So the ordering must be ok.

Are you sure my code to have cf_id in the subject is correct?
GreyHead 29 Jan, 2010
Hi pnut,

Sorry for the delay, I dug in the code and found a way to get it to work.

The OnSubmit Before box will not work because it is still executed before the DB save.

But you can put the code into the Email Template and then it works OK
<?php
$id = $MyForm->tablerow["jos_chronoforms_my_form_name"]->cf_id; 
$posted['subject'] = 'some text '.$id;
?>
Note: to put PHP into the Email template you must set "Use Template Editor" to 'No' in the Email setup.

Bob
pnut 29 Jan, 2010
Hi Bob,

That works fantastic!

Thank you so much for your time and effort.

Had chronoforms installed through the administrator whom purchased it about 2 weeks ago. But so satisfied when I saw that now CURL is implemented, I bought a license for another client that uses SalesForce and still wants the Joomla email template received.

Perfect solution. What a good product you have running! And the support. Even better!
GreyHead 29 Jan, 2010
Hi pnut,

Thank you.

I posted a beta version of an improved cURL plugin earlier today in another thread. Might be worth looking at.

Bob
pnut 29 Jan, 2010
Hi Bob,

Could you post the link to that? I did a search in the forum on "cURL" but didn't find it.

Hope to hear from you soon.

With best regards,

Piet Nutbey
Marenka 19 Feb, 2010
Greetings,

I was looking for a way to add the cf_id in the e-mail template and tried out the following code Piet posted in this thread:
<?php echo "Number: ".$MyForm->tablerow["jos_chronoforms_nlr_onlinejudgeregistration"]->cf_id;?>

In the code I've changed the name of the table, but it doesn't seem to find the column or the table itself. When I sent a test-mail to myself all I see printed is 'Number'.
The form does save the data in the into the table and I've also changed the run order (Order of Autogenerated block:1, Order of Plugins block: 2 and Order of OnSubmit block: 3) so that the data will be saved to the database before sending a confirmationmail. *If this is the correct way of course*

The name of the table is Reserveren. So this is what my code looks like:
<?php echo "Number: ".$MyForm->tablerow["jos_chronoforms_Reserveren"]->cf_id;?>

Is it possible that it got saved in something else than jos_chronoforms?
GreyHead 19 Feb, 2010
Hi Marenka,

The table_name in tablerow["table_name"] should be exactly the same as the table name in the database.

Bob
Marenka 19 Feb, 2010
Afaik the tablename is exactly the same as the table name in the database. Even with the capitalletter. I do see instead of jos_'component' oywn_'component'. What do you think about it. I'll prolly be back after the weekends, so I wish you a nice weekend and thanks for the help. ^^
GreyHead 19 Feb, 2010
Hi marenka,

What happened when you tested using the correct table name in the code?

Bob

PS jos_ is the default table prefix used by Joomla but it can be set to something different, looks like your site has been set up with oywn_ as the prefix.
Marenka 22 Feb, 2010
Once again only 'Number:' gets shown. Maybe it's because of the run order. I tried all possible combinations (jos_, oywn_, etc.)
Is there a way to find the prefix/link to the table in one of the chronoform files?
GreyHead 22 Feb, 2010
Hi Marenka,

Look at the database using PHPMyAdmin to be certain.

You can also see a list of all the database tables on the DB Connection tab of any form.

Bob
zaouyass 15 May, 2011
Hello,

I wanted to send the value of "cf_id" email but without success.
Does someone can tell me the steps to do?
This topic is locked and no more replies can be posted.