Hi,
if someone wants to use LiveDocx Services from Zend Framework in MODX Revo to create .docx files using MODX - maybe these tips can help.
Content-Type
Set up a new content-type called "DOCX" with these settings:
MIME-Type: application/vnd.openxmlformats .docx
File-Type: .docx
Binary: Yes
I also added the MIME-Type to the ht.access file, maybe it wasn’t necessary:
AddType application/vnd.openxmlformats .docx
Ressource
Create a new document with the empty template. Place the cached snippet with the LiveDocx call in it. If you make it un-cached, it won’t work! (Perhaps I messed something up in another place, but for me, it just worked cached...)
Set Content-Type to "DOCX" and Content-Disposition to "attachment". Make ressource uncached.
Snippet-Code
//Load Zend
define('LIBRARY_PATH', '/pathToZendLibraryfolder/libraries/'); // Update as appropriate
ini_set('include_path',
ini_get('include_path') . PATH_SEPARATOR . LIBRARY_PATH);
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
//LiveDocx
$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();
$phpLiveDocx->setUsername('yourLiveDocxUsername')
->setPassword('yourLiveDocxPassword');
$phpLiveDocx->setRemoteTemplate('templateName.docx');
$phpLiveDocx->assign('MergeField1', 'data')
->assign('MergeField2', 'data');
$phpLiveDocx->createDocument();
$document = $phpLiveDocx->retrieveDocument('docx');
return $document;
I hope it will help you.
Links:
Zend-Framework download:
http://framework.zend.com/download/latest
LiveDocx:
http://www.livedocx.com