2016-01-05 154 views
1
中被靜態調用

剛開始學習joomla並且在php中有點不好,我不知道我怎樣才能做出非靜態調用。 收到此錯誤:嚴格的標準:非靜態方法MenuHelper :: getArticleByID()不應該被靜態調用在嚴格標準:非靜態方法MenuHelper :: getArticleByID()不應該在

<?php 

defined('_JEXEC') or die; 

$base = JURI::base(true); 
$menu = JFactory::getApplication()->getMenu(); 
$item = $menu->getMenu(); 

include __DIR__ . '/helper.php'; 

?> 
<div class="container"> 
<div class="item support"> 
    <div class="content"> 
     <div class="title"> 
      <span class="name"><a href="<?php echo $item[106]->flink; ?>" class="rumble"><?php echo $item[106]->title; ?></a></span> 
      <span class="icon"><img src="<?php echo $base; ?>/templates/tehnos/images/man.png" alt="" /></span> 
     </div> 
     <div class="text"> 
      <h3><?php echo MenuHelper::getArticleByID(2)->title; ?></h3> 
      <?php echo MenuHelper::getArticleByID(2)->introtext; ?> 
     </div> 
    </div> 
</div> 
<div class="item center"> 
    <div class="content"> 
     <div class="title">+ 
      <span class="name"><a href="<?php echo $item[107]->flink; ?>" class="rumble"><?php echo $item[107]->title; ?></a></span> 
      <span class="icon"><img src="<?php echo $base; ?>/templates/tehnos/images/man.png" alt="" /></span> 
     </div> 
     <div class="text"> 
      <h3><?php echo MenuHelper::getArticleByID(3)->title; ?></h3> 
      <?php echo MenuHelper::getArticleByID(3)->introtext; ?> 
     </div> 
    </div> 
</div> 
<div class="item service"> 
    <div class="content"> 
     <div class="title"> 
      <span class="name"><a href="<?php echo $item[108]->flink; ?>" class="rumble"><?php echo $item[108]->title; ?></a></span> 
      <span class="icon"><img src="<?php echo $base; ?>/templates/tehnos/images/man.png" alt="" /></span> 
     </div> 
     <div class="text"> 
      <h3><?php echo MenuHelper::getArticleByID(4)->title; ?></h3> 
      <?php echo MenuHelper::getArticleByID(4)->introtext; ?> 
     </div> 
    </div> 
</div> 
<div class="item events"> 
    <div class="content"> 
     <div class="title"> 
      <span class="name"><a href="<?php echo $item[109]->flink; ?>" class="rumble"><?php echo $item[109]->title; ?></a></span> 
      <span class="icon"><img src="<?php echo $base; ?>/templates/tehnos/images/man.png" alt="" /></span> 
     </div> 
     <div class="text"> 
      <?php echo MenuHelper::getArticleByID(5)->introtext; ?> 
     </div> 
    </div> 
</div> 
<div class="item standards"> 
    <div class="content"> 
     <div class="title"> 
      <span class="name"><a href="<?php echo $item[110]->flink; ?>" class="rumble"><?php echo $item[110]->title; ?></a></span> 
      <span class="icon"><img src="<?php echo $base; ?>/templates/tehnos/images/man.png" alt="" /></span> 
     </div> 
     <div class="circle"></div> 
     <div class="text"> 
      <?php echo MenuHelper::getArticleByID(6)->introtext; ?> 
     </div> 
    </div> 
</div> 

謝謝您的時間!

回答

0

那麼錯誤消息告訴你,MenuHelper中的方法似乎沒有被定義爲

public static function getArticleByID (...)
所以你可以做的是在include之後獲取MenuHelper的一個實例。

$menuHelper = new MenuHelper();

,然後在你的代碼

$menuHelper->getArticleByID()
更換
MenuHelper::getArticleByID()
。現在你應該擺脫錯誤信息。

+0

**謝謝你@ TheColaKid ** – kaishi

+0

不客氣! – theColaKid

相關問題