How to get the total subscibers?
This number should be in the Thank you message, the email, the subject etc
In the past I used Custom code with a PHP code
And used this {total} in various messages,
I can't get it work in V6
This number should be in the Thank you message, the email, the subject etc
In the past I used Custom code with a PHP code
And used this {total} in various messages,
I can't get it work in V6
<?
$db =& JFactory::getDBO();
$pst = "SELECT COUNT(*) AS %s FROM %s WHERE %s = %s";
$query = sprintf(
$pst,
$db->quoteName('items'),
$db->quoteName('nestv_chronoengine_chronoforms_data_basic'),
$db->quoteName('Datum'),
$db->Quote(JRequest::getString('Datum')));
$db->setQuery($query);
$result = $db->loadObject();
$total = $result->items+1;
$form->data['total'] = $total;
?>
Hi Kees,
You can keep on using your code, and change $form->data to $this->data, then use {data:total} instead, or use a "Data read" function type "count" and get the value using {var:function_name}.
Best regards,
Max
You can keep on using your code, and change $form->data to $this->data, then use {data:total} instead, or use a "Data read" function type "count" and get the value using {var:function_name}.
Best regards,
Max
Hi Max,
The PHP Option works now.
Data read" function type "count" and get the value using {var:function_name}.
Where can I find "type Count" ???
Rgds
Kees
The PHP Option works now.
Data read" function type "count" and get the value using {var:function_name}.
Where can I find "type Count" ???
Rgds
Kees
Hi Kees,
Its the "Select type" in the settings, where you select single, multiple, count or key/value pairs.
Best regards,
Max
Its the "Select type" in the settings, where you select single, multiple, count or key/value pairs.
Best regards,
Max
Hi Kees,
Yes, Read Data > Data settings > Select type
Best regards,
Max
Yes, Read Data > Data settings > Select type
Best regards,
Max
Hi Max
Selected
Quess this is what you ment...
Now the filtering conditions, I can see "Filtering settings", but how tpo filter.
Eg I wish to filter on Datum?
Then your quote : (var:function_name}, is this the modelname? eg Data46? so: {var:Data46}?
Pls advise
Cheers
Kees
Selected
Return the count of records matching the filtering conditions.
Quess this is what you ment...
Now the filtering conditions, I can see "Filtering settings", but how tpo filter.
Eg I wish to filter on Datum?
Then your quote : (var:function_name}, is this the modelname? eg Data46? so: {var:Data46}?
Pls advise
Cheers
Kees
Hi Kees,
In your code you select based on the Datum passed variable, so the conditions can be:
Best regards,
Max
In your code you select based on the Datum passed variable, so the conditions can be:
Datum:{data:Datum}
Best regards,
Max
Max
Cryptic to me
What and where??
How to get the number of subscribers, eg in my Thanks message if using Data Read
Still not clear to me, I'm sorry
Kees
Cryptic to me
What and where??
How to get the number of subscribers, eg in my Thanks message if using Data Read
Still not clear to me, I'm sorry
Kees
Hi Kees,
The code I posted should be in the "Where conditions" of the data read, then you can use {var:data_read_function_name}
Best regards,
Max
The code I posted should be in the "Where conditions" of the data read, then you can use {var:data_read_function_name}
Best regards,
Max
Hi Max,
A typo, it should be {var:read_data56}>>read_data56 is what you can see in the "black label"
So far so good, but the result is the total of subscribers ALREADY in the DB, so it has to add 1 to get the correct number
You could say, drag it to the bottom, but as I wish to use this "counter" to stop sending when a certain number of subscribers has reached, I would like to see the current number of subcribers, plus the one who's next to subscribe
{var:read_data56}+1
Any ideas on this
Rgds
Kees
A typo, it should be {var:read_data56}>>read_data56 is what you can see in the "black label"
So far so good, but the result is the total of subscribers ALREADY in the DB, so it has to add 1 to get the correct number
You could say, drag it to the bottom, but as I wish to use this "counter" to stop sending when a certain number of subscribers has reached, I would like to see the current number of subcribers, plus the one who's next to subscribe
{var:read_data56}+1
Any ideas on this
Rgds
Kees
Hi Kees,
Where do you want to use this value ?
If in a "Custom code" box then you can use:
For any where else, you will need to use a PHP function and echo the value:
In php:
And where you want to display the value: {fn:php_function_name}
Best regards,
Max
Where do you want to use this value ?
If in a "Custom code" box then you can use:
<?php echo (int)$this->get("read_data56") + 1; ?>
For any where else, you will need to use a PHP function and echo the value:
In php:
echo (int)$this->get("read_data56") + 1;
And where you want to display the value: {fn:php_function_name}
Best regards,
Max
Hi Kees,
A better way to control the registration numbers is to use an Event Switcher in the On Load event of the form and check the number of registrations there. You can double check in the On Submit event to be certain (there might just have been a new registration since the form was loaded).
Bob
A better way to control the registration numbers is to use an Event Switcher in the On Load event of the form and check the number of registrations there. You can double check in the On Submit event to be certain (there might just have been a new registration since the form was loaded).
Bob
Okay Max
For now the total displays, follwing this:
If I wish to stop sending when a max total has reached, should I make a new PHP block and an Eventswitcher?
Or can I make this with work in a current PhP block and update the current eventswitcher?
I now have this i the current PHP, but does nor work
For now the total displays, follwing this:
If I wish to stop sending when a max total has reached, should I make a new PHP block and an Eventswitcher?
Or can I make this with work in a current PhP block and update the current eventswitcher?
I now have this i the current PHP, but does nor work
$then = JFactory::getDate(JRequest::getString('Datum', 'now'));
$now = JFactory::getDate();
$diff = $then->toUnix() - $now->toUnix();
if ($diff > 61*24*60*60) {
return "early";
} elseif ($diff <13*24*60*60) {
return "late";
} else ((int)$this->get("read_data56") + 1) >2 {
return "max";
}
Hi Bob
Sorry, missed your comment
If in ON Load, this would mean, as soon as people wants to subscribe the form will not be loaded if a certailn value has reached, but with a systemessage ofcourse.
Sounds logic
But what should I put in the Dataprovider of the eventswitcher??
Sorry, missed your comment
If in ON Load, this would mean, as soon as people wants to subscribe the form will not be loaded if a certailn value has reached, but with a systemessage ofcourse.
Sounds logic
But what should I put in the Dataprovider of the eventswitcher??
Hi Kees,
I don't know much about CFv6 - in Cfv5 I would use a db query
Bob
I don't know much about CFv6 - in Cfv5 I would use a db query
<?php
$db = \JFactory::getDBO();
$query = "
SELECT COUNT(*)
FROM `#__some_table`
WHERE `???` = '???' ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count > ??? ) {
return 'full';
}
?>
Bob
Hi Bob,
In this scenario you are leaving the Read Data option, which is fine to me.
However, it works only in the On Submit area, to my opinion.
This code should be placed in a PHP event ( without the <?php and ?>), combined with an Event Switcher
THIS WORKS FINE FOR ME
One remark: It counts a specific value "WHERE `???` = '???' ;, but if I use a script, which you wrote a couple of years ago 😉, it has the flexability to count any of the choosen dates, if there different dates in a Select box
The PHP "name" should be in the Eventswitcher as dataprovider: {var:PHP_name}
So far so good, I leave the Read Data for what it is.
Last question, is it possible to put several PHP scripts in ONE PHP event, and thus extending the Event Switcher?
In this scenario you are leaving the Read Data option, which is fine to me.
However, it works only in the On Submit area, to my opinion.
This code should be placed in a PHP event ( without the <?php and ?>), combined with an Event Switcher
THIS WORKS FINE FOR ME
One remark: It counts a specific value "WHERE `???` = '???' ;, but if I use a script, which you wrote a couple of years ago 😉, it has the flexability to count any of the choosen dates, if there different dates in a Select box
$db =& JFactory::getDBO();
$pst = "SELECT COUNT(*) AS %s FROM %s
WHERE %s = %s";
$query = sprintf(
$pst,
$db->quoteName('items'),
$db->quoteName('nestv_chronoengine_chronoforms_data_testkees'),
$db->quoteName('datum'),
$db->Quote(JRequest::getString('datum')));
$result = $db->loadObject();
$total = $result->items+1;
$this->data['total'] = $total;
if (($result->items+1)>4){
return "Max";
}
The PHP "name" should be in the Eventswitcher as dataprovider: {var:PHP_name}
So far so good, I leave the Read Data for what it is.
Last question, is it possible to put several PHP scripts in ONE PHP event, and thus extending the Event Switcher?
Hi Kees,
Last question, is it possible to put several PHP scripts in ONE PHP event, and thus extending the Event Switcher?
Sorry, a late reply here, yes you can, all the code will be executed, but you can always return one value from the code.
Best regards,
Max
Last question, is it possible to put several PHP scripts in ONE PHP event, and thus extending the Event Switcher?
Sorry, a late reply here, yes you can, all the code will be executed, but you can always return one value from the code.
Best regards,
Max
This topic is locked and no more replies can be posted.