如果未设置ohanah_event_id
,我需要阻止访问此文件。
我怎么能做到这一点?
<?php
/**
* @package Ohanah
* @copyright Copyright (C) 2012 - 2016 Beyounic SA. All rights reserved.
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
* @link http://www.beyounic.com
*/
class ComOhanahViewTicketHtml extends ComOhanahViewHtml
{
protected function _fetchData(KViewContext $context)
{
parent::_fetchData($context);
if ($context->data->ticket->ohanah_event_id) {
$doc = JFactory::getDocument();
$translator = $this->getObject('translator');
$doc->setTitle($translator->translate('COM_OHANAH_TICKET') . ' - ' . $context->data->ticket->event->title);
}
}
}
答案 0 :(得分:0)
<?php
class ComOhanahViewTicketHtml extends ComOhanahViewHtml
{
protected function _fetchData(KViewContext $context)
{
parent::_fetchData($context);
if(!empty($context->data->ticket->ohanah_event_id)){
$context->data->ticket->ohanah_event_id;
$doc = JFactory::getDocument();
$translator = $this->getObject('translator');
$doc->setTitle($translator->translate('COM_OHANAH_TICKET') . ' - ' . $context->data->ticket->event->title);
}
else {
return false;}
}
}
?>
&#13;
你可以尝试使用条件和!空,如果它是空的,则返回false给函数