Hi,
I'm using ChronoForms as an enrollment system. So far I've figured how to use it and it just works beautiful. Especially the ability to use php code is a great thing. Big compliment!
So I display the persons enrolled as a list in the Frontend - just as it is explained here in other posts.
There is only one thing, I havn't figured out yet - is there a way to have a list that is shown in the frontend exported as csv? I don't mean going to the backend and using the export function there. The users only have access to the frontend and I want to give them the possibility to export the data as csv.
As the function (exporting csv) itself is there (although only in the backend), I wondered, if I could use that from the frontend also. Have you got any ideas?
Help is much appreciated, thanks in advance,
Kristian
I'm using ChronoForms as an enrollment system. So far I've figured how to use it and it just works beautiful. Especially the ability to use php code is a great thing. Big compliment!
So I display the persons enrolled as a list in the Frontend - just as it is explained here in other posts.
There is only one thing, I havn't figured out yet - is there a way to have a list that is shown in the frontend exported as csv? I don't mean going to the backend and using the export function there. The users only have access to the frontend and I want to give them the possibility to export the data as csv.
As the function (exporting csv) itself is there (although only in the backend), I wondered, if I could use that from the frontend also. Have you got any ideas?
Help is much appreciated, thanks in advance,
Kristian
Hi Kristian,
I've never tried it, but I don't see why you couldn't copy some of the back end code into the form HTML box and edit it to create a download link.
Start out with the BackupCSV function code at the end of admin.chronocontact.php
Bob
I've never tried it, but I don't see why you couldn't copy some of the back end code into the form HTML box and edit it to create a download link.
Start out with the BackupCSV function code at the end of admin.chronocontact.php
Bob
Hi Bob,
I tried that. Unfortunately it didn't quite work out. What I got was the html code with the csv-export embedded. That ist the csv-export was at the position, where normally the content of the form would be. So I think the problem is, that the page gets created and the form code gets excecuted "in between". So as a download, I get the html code and the export. Somehow I'm stuck here ...
Thanks for the hint!
Kristian
I tried that. Unfortunately it didn't quite work out. What I got was the html code with the csv-export embedded. That ist the csv-export was at the position, where normally the content of the form would be. So I think the problem is, that the page gets created and the form code gets excecuted "in between". So as a download, I get the html code and the export. Somehow I'm stuck here ...
Thanks for the hint!
Kristian
I found the solution in another forum. If I add a simply die() at the end of the csv export function, it works perfectly!
What happens: Joomla prepares the headers to be sent out when the frontpage is created. If I stop creating the frontpage by adding a die(), then I can send the file without a problem.
Hope this helps.
Thanks,
Kristian
What happens: Joomla prepares the headers to be sent out when the frontpage is created. If I stop creating the frontpage by adding a die(), then I can send the file without a problem.
Hope this helps.
Thanks,
Kristian
Hi Kristian,
I'm a bit behind with the forum . . . looks like you've found a good answer here. The Joomla index2.php might also work - this creates a page without all the Joomla template content.
Bob
I'm a bit behind with the forum . . . looks like you've found a good answer here. The Joomla index2.php might also work - this creates a page without all the Joomla template content.
Bob
Hey Bob,
this is exactly what I need - but now I'm getting the "you're not authorized to view" error.
I have a published menu to it ... (I really hate this error)
if I use index.php?option=com_chronocontact&chronoformname=betafeedback it works...
if i use index2.php?option=com_chronocontact&chronoformname=betafeedback i get the error...
any thoughts?
thanks
Rod<br><br>Post edited by: rodsdesign, at: 2008/02/13 19:24
this is exactly what I need - but now I'm getting the "you're not authorized to view" error.
I have a published menu to it ... (I really hate this error)
if I use index.php?option=com_chronocontact&chronoformname=betafeedback it works...
if i use index2.php?option=com_chronocontact&chronoformname=betafeedback i get the error...
any thoughts?
thanks
Rod<br><br>Post edited by: rodsdesign, at: 2008/02/13 19:24
Hi Rod,
I suspect that this is a SEF intervention - it assumes that index2.php is an admin page. Can you try turning off SEF (assuming that you have it on) and see if that makes a difference?
I just checked on my test site here (no SEF) and both urls work OK, one with the Joomla gubbins and the other without.
Bob
I suspect that this is a SEF intervention - it assumes that index2.php is an admin page. Can you try turning off SEF (assuming that you have it on) and see if that makes a difference?
I just checked on my test site here (no SEF) and both urls work OK, one with the Joomla gubbins and the other without.
Bob
:(
well - i thought you were onto something... but alas - still not working.
I'm on Joomla! 1.013 and chronoforms 2.3.8
I'm open to any suggestion at this point...
thanks
well - i thought you were onto something... but alas - still not working.
I'm on Joomla! 1.013 and chronoforms 2.3.8
I'm open to any suggestion at this point...
thanks
Hi Rod,
Please remind me what you are trying to do here . . . I've gotten lost in the threads.
Is your site on-line so I can take a look?
Bob
Please remind me what you are trying to do here . . . I've gotten lost in the threads.
Is your site on-line so I can take a look?
Bob
Hi,
This should work :
This should work :
global $mosConfig_absolute_path, $database, $mosConfig_dbprefix;
$formname = $_GET['chronoformname'];
$database->setQuery( "SELECT id FROM #__chrono_contact WHERE name='".$formname."'" );
$formid = $database->loadResult();
$tablename = $mosConfig_dbprefix."chronoforms_".$formid;
$tables = array( $tablename );
$result = $database->getTableFields( $tables );
$table_fields = array_keys($result[$tablename]);
$database->setQuery( "SELECT * FROM ".$tablename."" );
$datarows = $database->loadObjectList();
$titcol = 0;
foreach($table_fields as $table_field){
if($titcol){$csvline .=",";}
$csvline .= $table_field;
$titcol++;
}
$csvline .="\n";
$datacol = 0;
$rowcount = 1;
foreach($datarows as $datarow){
foreach($table_fields as $table_field){
if($datacol){$csvline .=",";}
$csvline .= '"'.addslashes($datarow->$table_field).'"';
$datacol++;
}
$csvline .="\n";
$datacol = 0;
$rowcount++;
}
if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT'])) {
$UserBrowser = "Opera";
}
elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT'])) {
$UserBrowser = "IE";
} else {
$UserBrowser = '';
}
$mime_type = ($UserBrowser == 'IE' || $UserBrowser == 'Opera') ? 'application/octetstream' : 'application/octet-stream';
@ob_end_clean();
ob_start();
header('Content-Type: ' . $mime_type);
header('Expires: ' . gmdate('D, d M Y H:i:«»s') . ' GMT');
if ($UserBrowser == 'IE') {
header('Content-Disposition: inline; filename="' . "ChronoForms - ".$formname." - ".date("j_n_Y"«»).'.csv"');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
}
else {
header('Content-Disposition: attachment; filename="' . "ChronoForms - ".$formname." - ".date("j_n_Y"«»).'.csv"');
header('Pragma: no-cache');
}
print $csvline;
exit();
This topic is locked and no more replies can be posted.