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


Strict standards: Non-static method MenuHelper::getArticleByID() should not be called statically in

刚开始学习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>

感谢您抽出时间!

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

publicstatic函数getArticleByID(…)
因此,您可以做的是在include之后获取MenuHelper的一个实例。
$menuHelper=new menuHelper()

然后更换

MenuHelper::getArticleByID()
与代码中的
$MenuHelper->getArticleByID()[/pre>。现在您应该去掉错误消息。