Buy Now
Sign in

Total subscribers

SPABO , April 14 2017, 18:17
S
SPABO 639
April 14 2017, 18:17 #366928
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

<?
$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;
?>
admin 29
April 14 2017, 19:09 #366933
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
Max
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!
S
SPABO 639
April 15 2017, 15:10 #366951
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
admin 29
April 15 2017, 16:17 #366953
Hi Kees,

Its the "Select type" in the settings, where you select single, multiple, count or key/value pairs.

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!
S
SPABO 639
April 15 2017, 16:33 #366954
In Data Read???? Not in mine...
admin 29
April 15 2017, 19:11 #366963
Hi Kees,

Yes, Read Data > Data settings > Select type

Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!
S
SPABO 639
April 17 2017, 10:27 #367025
Hi Max
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
admin 29
April 17 2017, 12:20 #367027
Hi Kees,

In your code you select based on the Datum passed variable, so the conditions can be:

Datum:{data:Datum}


Best regards,
Max
Max
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!
S
SPABO 639
April 17 2017, 15:10 #367034
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
admin 29
April 17 2017, 16:28 #367037
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
Max
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!
S
SPABO 639
April 17 2017, 17:22 #367038
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
admin 29
April 17 2017, 19:14 #367039
Hi Kees,

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
Max
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!
GreyHead 64
April 18 2017, 08:09 #367056
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
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
S
SPABO 639
April 18 2017, 08:21 #367057
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
$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";
}
S
SPABO 639
April 18 2017, 08:38 #367059
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??
GreyHead 64
April 18 2017, 13:17 #367068
Hi Kees,

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
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
S
SPABO 639
April 18 2017, 16:51 #367083
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

$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?
admin 29
April 25 2017, 18:51 #367431
 Answer
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
Max
If your main question got answered then please mark the answer using the button!
Did you try the new ChronoForms7 ? if yes then please send us your comments!!