JOOMLA 3.x如何在检查后隐藏模板

问题描述 投票:1回答:1

我正在尝试了解Joomla语言,并且遇到这种情况:

models/calcoloonline.php中,我具有此功能

public function estraivariabili()
{
    $db = JFactory::getDBO();

    // Put the result into a variable first, then return it.
    $value = $db->setQuery("SELECT * FROM #__calcolo_imposte")->loadObjectList();

    if ($value != NULL)
    {
        return $value;
    }
    else
    {
        return JFactory::getApplication()->enqueueMessage(JText::_('COM_CALCOLO_IMPOSTE_IMPORTI_NON_DEFINITI'), 'type');
    }
}

这很好用,但是我想在检查返回值是否为NULL之后,我想隐藏显示default.php并仅在JText上显示消息。

我该怎么做?

joomla hide default
1个回答
0
投票

出于您的目的,您只需从$value函数返回model并在view.html.phpdisplay()函数中调用该函数。

default.php文件中,检查$value的可用性并显示您的内容。

例如,您将数据存储在view.php.html。看起来像

public function display($tpl = null)
{
    $model = $this->getModel();

    $this->value = $model->estraivariabili();
    return parent::display($tpl);
}

您的default.php文件为

<?php if (!empty($this->value)) { ?>
    <h1>The value is not empty.</h1>
<?php } else {
    // value not found :(
    JFactory::getApplication()->enqueueMessage(JText::_('NOT_FOUND_MESSAGE'), 'warning');
} ?>
© www.soinside.com 2019 - 2024. All rights reserved.