limit register in form by recorder

How to limit the number of records in a form (for example if l wants organize a event with only 7 places)
The limit conserne lines records in a particular form (and no a limit by user a limit by in form)
 
Our 'limit' plugin currently expects to limit on a per user basis.

I'm looking at the code to see if it would be simple to allow a limit not set per-user.

Would you have some other element which you want to group the count by? Like (say) an event name? Or would this just be a very simple case of you only want a given table (List) to have seven rows, period? So one List per event?

-- hugh
 
OK, it looks like it wouldn't be too hard to make the "User element" optional in the 'limit' form plugin.

But I do need to understand if you are needing to group the count by some other element, or if yu are tlaking about just limiting the total number of rows in a list, period.

In other words, if you are going to organize two events, Event A and Event B, will they have their own tables/lists, or will they share a common events table, with an event_name element that you need to do the count on (so "no more than 7 rows where event_name = Event A").

-- hugh
 
Think you very much ,exactly l want just limiting the total number of rows in a list, for a period. if l want organize two events, Event A and Event B, their own tables/lists,
 
Personally, I would do that with a little custom coding in an article. Use something like Sourcerer, so you can embed PHP in a standard J! article. Then you can write some simple code that checks to see how many rows are in the table, when that article page is loaded, and either display an error message, or output the {fabrik ...} string needed for your form. Something like this:

PHP:
$db = FabrikWorker::getDbo();
$query = $db->getQuery(true);
$query->select('COUNT (*) AS num_rows')->from('yourtable');
$db->setQuery($query);
$num_rows = (int) $db->loadResult();
if ($num_rows >= 7) {
  echo "This event is already fully booked";
}
else {
  echo "{fabrik view=form formid=123}";
}

Obviously change this to suit ... 'yourtable' becomes your table name, the 7 becomes the max number you want, and the 123 becomes the numeric form ID of your form (number in left most column of the main list of Forms on the backend).

The above would need to be wrapped in {source} tags, after installing the Sourcerer extension from NoNumber.

Also make sure the Fabrik Content Plugin is installed and published/enabled.

-- hugh
 
thinks you very much.l try your exemple (http://fabrik.reseausolidaire.fr/index.php/inscription-controlee) l have this error message :( No id set in fabrik plugin declaration)
But sourcerer in free version don't accept the php code (however in website l read that php code is a free option but in the parameter of sourcerer php option appear with 'acces in pro version only' . Are you a other solution or you know a other extention free can integreted php code in article joomla ?
 
Using the 'source' tags with Sourcerer is definitely a free option.

Make sure you edit your article in plain text mode, not WYSIWYG, as the WYSIWYG editor often puts HTML markup around your tags and code. So edit that article again, in plain text, and make sure you remove any extra formatting the WYSIWYG mode may have added.

The reason you are getting that error is because the PHP isn't executing.

-- hugh
 
HEllo , l deactiveted the wysiwyg (in parameter joomla ) and l paste this code :

{source} <? Php $db = FabrikWorker::getDbo(); $query = $db->getQuery(true); $query->select('COUNT (*) AS num_rows')->from('Plateforme adh?rents'); $db->setQuery($query); $num_rows = (int) $db->loadResult(); if ($num_rows >= 30) { echo "D?sol? , les inscriptions sont clotur?es. MErci de votre compr?hention."; } else { echo "{fabrik view=form formid=47}"; } ?> {/source}

and l have this error message :


Parse error: syntax error, unexpected T_VARIABLE in /home/reseaus8/public_html/seblod/plugins/system/sourcerer/helper.php(553) : runtime-created function on line 7

Fatal error
: Function name must be a string in /home/reseaus8/public_html/seblod/plugins/system/sourcerer/helper.php on line 558
 
Do you literally have a space between the ? and Php, with a capital P, or is it (as it should be):

Code:
<?php

Also, your table name looks wrong in the from(), a MySQL table name won't have spaces and accented characters in it.

-- hugh
 
l take this code :

{source}
<?php
$db = FabrikWorker::getDbo();
$query = $db->getQuery(true);
$query->select('COUNT (*) AS num_rows')->from('plateforme_adherents2');
$db->setQuery($query);
$num_rows = (int) $db->loadResult();
if ($num_rows >= 30) {
echo "D?sol? , les inscriptions sont clotur?es. MErci de votre compr?hention.";
}
else {
echo "";
}
?>
{/source}

and now l have this error message :
Fatal error: Call to a member function getConnection() on a non-object in /home/reseaus8/public_html/seblod/components/com_fabrik/helpers/parent.php on line 1385
 
I can confirm the issue.

If your table plateforme_adherents2 is in the standard Joomla database use
$db = FabrikWorker::getDbo(true);
or
$db = JFactory::getDbo();

Additionally it must be
COUNT(*) without space between COUNT and (*)
 
think you very it work but when the condition is on 'else' l have this error message :
"No id set in fabrik plugin declaration"

code :
{source}
<?php
$db = FabrikWorker::getDbo(true);
$query = $db->getQuery(true);
$query->select('COUNT(*) AS num_rows')->from('plateforme_adherents2');
$db->setQuery($query);
$num_rows = (int) $db->loadResult();
if ($num_rows >= 40) {
echo "D?sol? , les inscriptions sont clotur?es. Merci de votre compr?hention.";
}
else {
echo "{fabrik view=form formid=47}";
}
?>
{/source}
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top