Forums

Insert article into an confirmation email

huubs 18 Mar, 2016
Hello,

I saw this post: http://www.chronoengine.com/forums/posts/f2/t20555.html which explains how to insert article text into a variable so you can use it anywhere in the form. But I've used this code but it's not working. I used the debugger and the article_text variable just doesn't come up, it looks like it's not saved at all. Maybe is the code outdated?
GreyHead 18 Mar, 2016
Answer
Hi Huubs,

It's a bit out of date - only five years old. Please try this version, there are a few small changes
?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();
$form->data['article_text'] = $article_text; 
?>
Then use {article_text} in the email template.

Bob
huubs 19 Mar, 2016

Hi Huubs,

It's a bit out of date - only five years old. Please try this version, there are a few small changes

?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();
$form->data['article_text'] =$article_text; 
?>
Then use {article_text} in the email template.

Bob



Awesome as always.Thank you!
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger