cakephp 2.x+;OpenTBS

cakephp 2.x+;OpenTBS,cakephp,cakephp-2.x,opentbs,Cakephp,Cakephp 2.x,Opentbs,我正在尝试使用CakePHP2.x,但遇到了一些问题。我找到了下面的线程,并遵循了它,但这是针对CakePHP1.x的 我的不同之处如下: TbsHelper class TbsHelper extends Helper { function getOpenTbs() { App::import('Vendor', 'tbs/tbs_class_php5'); App::import('Vendor', 'tbs/tbs_plugin_opentbs'); $t

我正在尝试使用CakePHP2.x,但遇到了一些问题。我找到了下面的线程,并遵循了它,但这是针对CakePHP1.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;
    }

} 
邮件合并功能(将导出功能替换为下载而不是查看)

我收到以下错误:致命错误:在第408行的/home/village/public\u html/app/Controller/ContactsController.php中对非对象调用成员函数getOpenTbs()

第408行是:$otbs=$this->Tbs->getOpenTbs()

知道会发生什么吗


谢谢

您是否在ContactsController上声明了TBSHelper?不,我所做的只是这一行:$this->helpers[]='Tbs';我想这会让助手感到压力。我只是把它放在顶部:App::uses('TbsHelper','View/Helper');我仍然会犯同样的错误。Thanksry在这里声明like谢谢,我只是尝试了这个:public$helpers=array('Tbs');我仍然收到相同的错误。等一下,您正在尝试在控制器中使用helper吗?它们仅在查看时可用。请看这里:
// 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);

    }