严格标准:非静态方法不应静态调用MenuHelper :: getArticleByID()

时间:2016-01-05 13:13:52

标签: php joomla

刚开始学习joomla并且在php上有点不好我不知道如何进行非静态调用。 得到此错误:严格标准:非静态方法不应在

中静态调用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>

感谢您的时间!

1 个答案:

答案 0 :(得分:0)

错误消息告诉您,MenuHelper中的方法似乎没有被定义为

public static function getArticleByID (...)
所以你可以做的是在include之后获取MenuHelper的一个实例。

$menuHelper = new MenuHelper();

然后更换

MenuHelper::getArticleByID()
代码中包含
$menuHelper->getArticleByID()
。现在你应该摆脱错误信息。