2013-09-21 57 views
1

我有一個我不能使用一個輔助函數的Joomla從內部view.html.php

我在定點> helpers->的輔助文件document_management.php

調用助手該文件中的類 定義('_ JEXEC')或死亡;

  /** 
      * Document_managment helper. 
      */ 
      class Document_managmentHelper 
      { 

      function testFunction() 
      { 
       $textis= "hello"; 
       return $textis; 
      } 
      } 

在我的定點>則須─>文檔 - > view.html.php

我試圖調用該函數testFunction:

  $callingCard = Jview::loadHelper('Document_managment'); 
      //require_once JPATH_COMPONENT.'/helpers/document_managment.php'; 
      $getprofileinfo = Document_managmentHelper::testFunction(); 
      echo getprofileinfo;  
      echo "test is ". JPATH_COMPONENT.'/helpers/document_managment.php'; 

我只是得到

PHP致命錯誤:無法在/var/www/vhosts/mydomain.com/httpdocs/components/com_document_managment/views/document/view.html.php在線xx上找到'Document_managmentHelper'類xx

我無法弄清楚

+1

JView中?另外你的函數沒有被聲明爲靜態的,你不應該把它稱爲靜態的。你也不會說你在哪個版本,但在J +中它會是JViewLegacy。 – Elin

+0

@Elin:助手類_and_方法應該是靜態的;一些Joomla版本允許一些鬆弛,但最好是簡單地聲明兩者都是靜態的。 user1616338,它與require_once一起工作嗎?該類不加載... –

+0

我真的認爲小寫V是問題。 – Elin

回答

0

我按照以下方法叫助手在我的自定義組件的視圖的方法如default.php:

$isEnable = CustomFrontendHelper::getTheMethod('is_enable'); // a static function in the helper