Forums

Insert article content into response email

petersen 06 Jan, 2011
I have a form which directs the user to a thankyou page with the next event that my customer is running. I would like to send the content of this page (just the text) via email as a response.

I've added the email template, but need to know how to grab the content of the article and insert it.

Thanks
GreyHead 07 Jan, 2011
Hi petersen,

I think I replied to this in a PM?

You can get the article contents from the jos_content table, the text is in the introtext and possibly the fulltext columns.

Bob
petersen 07 Jan, 2011
Yes, thanks Bob.

How do I push the content into the email? I'm guessing in the onsubmit before? Does the email just have a variable I need to append?
GreyHead 07 Jan, 2011
Hi petersen,

I'd try creating a new variable in the OnSubmit Before box like
<?php
$query = "
  SELECT CONCAT(`introtext`, '<br />', `fulltext`) AS `article_text`
    FROM `#__content`
    WHERE `id` = XXX ;
";
$db =& JFactory::getDBO();
$db->setQuery($query);
$article_text = $db->loadResult();
JRequest::setVar('article_text', $article_text); 
?>
Then use {article_text} in the email template.

Bob
petersen 07 Jan, 2011
Ah of course. Will give a go.

Thanks Bob.
petersen 07 Jan, 2011
Hi Bob,

I tried the code, but initially only got {article_text} output in the email. I then wondered if it was that the field didn't exist in the actual form so I added it to the HTML and I got an empty email.

Debug info doesn't show the field either. The field contains HTML. Could that be a problem?

Form passed first SPAM check OK
Form passed the submissions limit (if enabled) OK
Form passed the Image verification (if enabled) OK
Form passed the server side validation (if enabled) OK
$_POST Array: Array ( [contactname] => XXXXX [email] => XXXXXX [telephone] => XXXXXX[message] => Test [chrono_verification] => qfmmi [submit] => submit [8018c11175337d2e09acbe108837247c] => 1 [1cf1] => a4acf1b1c6ae8769886c816692c6f65a [chronoformname] => contactus )
$_FILES Array: Array ( )
Form passed the plugins step (if enabled) OK
An email has been SENT successfully from (XXXX)XXXXXX to XXXXXX
An email has been SENT successfully from (XXXX)XXXXXX to XXXXXX
Debug End
GreyHead 07 Jan, 2011
Hi petersen,

Silly question, but have you got the article ID OK - the XXX in my code?

You shouldn't need to have the article_text in the Form HTML.

I'll try and run a test here later. Have to go run some errands right now.

Bob
GreyHead 07 Jan, 2011
Hi peteresen,

Ooops, sorry. I went back and fixed my post in case I try to use it again.

Bob
This topic is locked and no more replies can be posted.