Page 1 of 1
A hit counter for formbrowser?
Posted: Tue Sep 14, 2010 2:54 pm
by sam_m
Hello,
I have an online petition created using formbuilder and formbrowser which works a treat. I just wondered if it`s possible to have a little counter at the top of the page which will tell me how many petitions have been posted on the website?
Any thoughts would be greatly apreciated
Kind Regards
Sam
Re: A hit counter for formbrowser?
Posted: Tue Sep 14, 2010 4:21 pm
by Rolf
Hello sam_m
Create an UDT called
read_entries
Code: Select all
// Maximum excepted entries
$entries_max = ($params[max]);
// Read entries in FormBrowser
global $gCms;
$list = $gCms->smarty->get_template_vars('list');
$entries = count($list);
// Complex Mathematical Calculation :o)
$entries_left = $entries_max - $entries;
// Passing the parameters to the template
$smarty = &$gCms->GetSmarty();
$smarty->assign('entries_max', $entries_max);
$smarty->assign('entries', $entries);
$smarty->assign('entries_left', $entries_left);
You can call this udt in a page like:
Code: Select all
{cms_module module='FormBrowser' browser='your-name'}
{read_entries max='10'}
You can use the parameter
max if you want to limit the entries. You probably don't need this.
In a template or page you can use these strings:
{$entries} = Total entries in the database
{$entries_left} = Allowed entries left
{$entries_max} = Maximum entries allowed.
Hope this helps,
RolfÂ

Re: A hit counter for formbrowser?
Posted: Tue Sep 14, 2010 5:53 pm
by sam_m
Thank you Rolf,
Greatly appreciated

will give it ago now