Showing Template
Showing Template
I have an action in my module (action.ExportExcel.php) to export a list of contacts from DB to excel...as the name implies. The problem is this: The excel sheet gets exported (downloaded) with the entire template of the template. How do I make CMSMS not display the template for this specific admin action?
Re: Showing Template
ross2376,
Not quite clear to me what you mean with
Retrieve a row from the database;
Format its fields by catenating them with delimiters;
Write the formated row to a .csv file (not sure if this would be on the server or for example on your c:\ drive);
Close the .csv file;
Open .csv using Excel.
Please provide us with the steps taken.
Maybe action.exportquiz.php from the module Quizzard can be of help.
Not quite clear to me what you mean with
. I take it that you do something like:entire template of the template
Retrieve a row from the database;
Format its fields by catenating them with delimiters;
Write the formated row to a .csv file (not sure if this would be on the server or for example on your c:\ drive);
Close the .csv file;
Open .csv using Excel.
Please provide us with the steps taken.
Maybe action.exportquiz.php from the module Quizzard can be of help.
Re: Showing Template
Code: Select all
if (!isset($gCms))
exit;
# Assign smarty variable by reference for easier use and cleaner code
$Smarty =& $this->smarty;
# Check appropriate user permissions
if (!$this->CheckPermission($this->Lang('PermissionExport')))
header('Location: http://' . $_SERVER['SERVER_NAME'] . '/admin');
# Generate administrative navigation
$this->DisplayAdminNav($id, $params, $returnid);
# Clean output buffers
@ob_clean();
@ob_clean();
# Send headers to identify as excel document
header('Content-type: application/vnd.ms-excel; name=\'excel\'');
header('Content-Disposition: attachment; filename=Contacts.xls');
header('Pragma: no-cache');
header('Expires: 0');
# Retrieve array of contact objects
$Contacts = $this->GetContact();
# Perform misc operations to ready data for listing
foreach ($Contacts AS $key => $value)
$Contacts[$key]->Date = date('F j, Y g:i A', $Contacts[$key]->Date);
$Smarty->Assign('Contacts', $Contacts);
# Display Template
echo $this->ProcessTemplate('ExportExcel.tpl');
# Exit application
exit;
Re: Showing Template
View Printing module and PDF creation (createpdf.php)ross2376 wrote: I thought about just making a standalone script that doesnt use a CMS module action but thats tacky in my mind. How do I make this action not load the global template?
Alby
Re: Showing Template
Thanks. I looked that up and I found the ContentPostRender() method to control content posting, however, this seems to only be valid for the frontend? My action is an admin action. How can I control admin content?
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: Showing Template
the link to your action should have 'showtemplate=false' as one of the parameters.
See how the Uploads module, and other similar modules (modules that send files).
See how the Uploads module, and other similar modules (modules that send files).
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: Showing Template
Code: Select all
$ExportLink = $this->CreateLink($id, 'ExportExcel', $returnid, 'here', array('showtemplate' => 'false'));
If so, that didn't work for me.