I have put this code in Custom code Before sending emails
And resp "subject" abd "subject_1" in teh email tabs DYNAMIC
However, it does not work
<?
$db =& JFactory::getDBO();
$pst = "SELECT COUNT(*) AS %s FROM %s
WHERE %s = %s";
$query = sprintf(
$pst,
$db->nameQuote('items'),
$db->nameQuote('j17_chronoforms_data_Test2'),
$db->nameQuote('Wedstrijddatum'),
$db->Quote(JRequest::getString('Wedstrijddatum')));
$db->setQuery($query);
$result = $db->loadObject();
$total = $result->items+1;
JRequest::setVar('total', $total, 'post');
?>
<?php
$Wedstrijddatum = JRequest::getString('Wedstrijddatum');
JRequest::setVar('subject', 'Nr. ' . $total . ' Nieuwe inschrijving Pitch en Puttwedstrijd dd '.$Wedstrijddatum);
?>
<?php
$Wedstrijddatum = JRequest::getString('Wedstrijddatum');
JRequest::setVar('subject_1', 'Nr.'. $total . ' Uw inschrijving Pitch en Putt wedstrijd dd ' . $Wedstrijddatum);
?>
And resp "subject" abd "subject_1" in teh email tabs DYNAMIC
However, it does not work
Hi SPABO,
It won't work because you have an error in your code. What value do you expect in $result->items ??? And why isn't it there?
Bob
It won't work because you have an error in your code. What value do you expect in $result->items ??? And why isn't it there?
Bob
Hi SPABO,
What are you trying to do here exactly ?
Regards,
Max
What are you trying to do here exactly ?
Regards,
Max
This code works perfectly in V3 (Joomla 1.5)
It should count the number of rows in the table, and it should be in teh subject of the emails
It should count the number of rows in the table, and it should be in teh subject of the emails
Hi Max,
To put it in a better way:
This code should count from a table called j17_chronoforms_data_Test2:
Nbr of Records, which hold the selected(posted) "Wedstrijddatum"
(The form contains a fielname "Wedstrijddatum", this is a selectbox)
To put it in a better way:
This code should count from a table called j17_chronoforms_data_Test2:
Nbr of Records, which hold the selected(posted) "Wedstrijddatum"
(The form contains a fielname "Wedstrijddatum", this is a selectbox)
Hi SPABO,
From the style used that's Frederik's code maybe, not mine.
Try replacing
Bob
From the style used that's Frederik's code maybe, not mine.
Try replacing
JRequest::setVar('total', $total, 'post');
with $form->data['total'] = $total;
as ChronoForms v4 only reads the posted variables once, after that it uses it's own internal $form->data array.Bob
Hi Bob, I belief you are correct, it was Frederic's !
Tried the following:
However, no success. Hope it will work again as I have quite some forms with this code
Tried the following:
<?
$db =& JFactory::getDBO();
$pst = "SELECT COUNT(*) AS %s FROM %s
WHERE %s = %s";
$query = sprintf(
$pst,
$db->nameQuote('items'),
$db->nameQuote('j17_chronoforms_data_Test2'),
$db->nameQuote('Wedstrijddatum'),
$db->Quote(JRequest::getString('Wedstrijddatum')));
$db->setQuery($query);
$result = $db->loadObject();
$total = $result->items+1;
$form->data['total'] = $total;
?>
However, no success. Hope it will work again as I have quite some forms with this code
Hi,
Try to replace:
with:
does that work ? how do you check it ? do you have {total} in your email template ? or do you use the debugger ?
Try to replace:
$result = $db->loadObject();
$total = $result->items+1;
$form->data['total'] = $total;
with:
$result = $db->loadResult();
//$total = $result->items+1;
$form->data['total'] = $result + 1;
does that work ? how do you check it ? do you have {total} in your email template ? or do you use the debugger ?
Hi Bob,
I belief the problem could also be to get the (dynamic) subject in the email
This is the Custom code on teh event : On Submit
If I fill in subject in the dynamic part of the email event, it replies "DEFAULT SUBJECT"
I belief the problem could also be to get the (dynamic) subject in the email
This is the Custom code on teh event : On Submit
<?php
$Wedstrijddatum = JRequest::getString('Wedstrijddatum');
JRequest::setVar('subject', 'Nr. ' . $total . ' Nieuwe inschrijving Pitch en Puttwedstrijd dd '.$Wedstrijddatum);
?>
If I fill in subject in the dynamic part of the email event, it replies "DEFAULT SUBJECT"
Hi SPABO,
Please see this post from earlier in this thread. You need to make the same change here.
Bob
Please see this post from earlier in this thread. You need to make the same change here.
Bob
I don't have a clou..
Like this??
Like this??
<?php
$Wedstrijddatum = JRequest::getString('Wedstrijddatum');
$form->data('subject', 'Nr. ' . $total . ' Nieuwe inschrijving Pitch en Puttwedstrijd dd '.$Wedstrijddatum);
?>
Hi SPABO,
Time to get a clue . . .
Does that look like the code I posted earlier? (No) More importantly, does it work?? (No)
Bob
Time to get a clue . . .
Does that look like the code I posted earlier? (No) More importantly, does it work?? (No)
Bob
Okay, a small step further
This is the code to get de subject in the dynamic part
It shows the text, the "datum" , but not "total"
This is the code to get de subject in the dynamic part
<?php
$form->data['subject'] = '`Dear etc etc - '.$form->data['datum'].' '.$form->data['total'];
?>
It shows the text, the "datum" , but not "total"
:D 😀 😀 😀 😀
Hey Bob,
Problem is now tackled, pls find the complete code
This isssue is now tackled Bob,
Thanks for letting me thinklightbulb lightbulb
Hey Bob,
Problem is now tackled, pls find the complete code
<?
$db =& JFactory::getDBO();
$pst = "SELECT COUNT(*) AS %s FROM %s
WHERE %s = %s";
$query = sprintf(
$pst,
$db->nameQuote('items'),
$db->nameQuote('j17_chronoforms_TEST3'),
$db->nameQuote('datum'),
$db->Quote(JRequest::getString('datum')));
$db->setQuery($query);
$result = $db->loadObject();
$total = $result->items+1;
$form->data['total'] = $total;
?>
<?php
$form->data['subject'] = 'Uw inschrijving P&P wedstrijd dd - '.$form->data['datum'].' U bent nr. '.$form->data['total'];
?>
<?php
$form->data['subject_1'] = 'Nwe.inschrijving P&P wedstrijd dd - '.$form->data['datum'].' Nr. '.$form->data['total'];
?>
This isssue is now tackled Bob,
Thanks for letting me thinklightbulb lightbulb
This topic is locked and no more replies can be posted.