I am trying to get OpenTBS to work with cakephp 2.x but am having some issues. I found the following thread and have followed it but this is for cakephp 1.x
The differences I made are as follows:
TbsHelper
class TbsHelper extends Helper
{
function getOpenTbs() {
App::import('Vendor', 'tbs/tbs_class_php5');
App::import('Vendor', 'tbs/tbs_plugin_opentbs');
$tbs = new clsTinyButStrong; // new instance of TBS
$tbs->Plugin(TBS_INSTALL, OPENTBS_PLUGIN); // load OpenTBS plugin
return $tbs;
}
}
mail_merge function (replacing the export function as a download instead of view)
// FUNCTION EXPORT MAIL MERGE
// -------------------------------------------------------------->
function mail_merge()
{
// Stop Cake from displaying action's execution time, this can corrupt the exported file
// Re-ativate in order to see bugs
//Configure::write('debug',0);
// LOAD THE TBS HELPER
// --------------------------------------------------------------->
$this->helpers[] = 'Tbs';
// GET THE CONTACTS
// ------------------------------------------------------------->
$contacts = $this->Contact->find('all', array('limit' => 20, 'contain' => FALSE));
//debug($contacts);
// Get a new instance of TBS with the OpenTBS plug-in
// ------------------------------------------------------------->
$otbs = $this->Tbs->getOpenTbs();
// Load the DOCX template
// ------------------------------------------------------------->
$otbs->LoadTemplate($this->webroot.'/files/data_files/enquiry_letter_sample.docx');
// Merge data in the template
// ------------------------------------------------------------->
$otbs->MergeBlock('r', $contacts);
// End the merge and export
// ------------------------------------------------------------->
$file_name = 'export.docx';
$otbs->Show(OPENTBS_FILE, $file_name);
}
I'm getting this error: Fatal error: Call to a member function getOpenTbs() on a non-object in /home/village/public_html/app/Controller/ContactsController.php on line 408
line 408 is: $otbs = $this->Tbs->getOpenTbs();
Any idea what might be going on?
Thanks