我试图让OpenTBS与 cakephp 2.x 一起工作,但遇到了一些问题。我找到了以下线程并遵循了它,但这是针对 cakephp 1.x
我所做的差异如下:
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 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);
}
我收到此错误:致命错误:在第 408 行的 /home/village/public_html/app/Controller/ContactsController.php 中的非对象上调用成员函数 getOpenTbs()
第 408 行是:$otbs = $this->Tbs->getOpenTbs();
知道会发生什么吗?
谢谢