我遇到了问题。 我尝试编辑我的内容,但是当我点击编辑时出现错误。 我得到的错误信息是:
警告:缺少Template :: error()的参数1,在第13行的C:\ xampp \ htdocs \ PassieCMS \ app \ cms \ edit.php中调用,并在C:\ xampp \ htdocs \ PassieCMS \ app中定义第87行\ core \ models \ m_template.php
注意:未定义的变量:在第89行的C:\ xampp \ htdocs \ PassieCMS \ app \ core \ models \ m_template.php中输入
这里是2个文件的代码
编辑页面:
<?php
include("../init.php");
if(isset($_POST['field']))
{
}
else
{
if(isset($_GET['id']) == FALSE || isset($_GET['type']) == FALSE)
{
$FP->Template->error();
exit;
}
$id = $FP->Cms->clean_block_id($_GET['id']);
$type = htmlentities($_GET['type'], ENT_QUOTES);
$content = 'Conent here';
$FP->Template->setData('block_id', $id);
$FP->Template->setData('block_type', $type);
$FP->Template->setData('cms_field', $FP->Cms->generate_field($type, $content), false);
//load view
$FP->Template->load(APP_PATH . 'cms/views/v_edit.php');
}
m_template页面
<?php
/*
Template Class
Handles all templating tasks - displaying templates, alerts & errors
*/
class Template
{
private $data;
private $alertTypes;
/*
Construtor
*/
function __construct() {}
/*
Functions
*/
function load($url)
{
include($url);
}
function redirect($url)
{
header("Location: $url");
}
/*
Get / Set Data
*/
function setData($name, $value, $clean = true)
{
if(clean)
{
$this->data[$name] = htmlentities($value, ENT_QUOTES);
}
else
{
$this->data[$name] = $value;
}
}
function getData($name)
{
if (isset($this->data[$name]))
{
return $this->data[$name];
}
else
{
return '';
}
}
/*
Get / Set Alerts
*/
function setAlertTypes($types)
{
$this->alertTypes = $types;
}
function setAlert($value, $type = null)
{
if ($type == '') { $type = $this->alertTypes[0]; }
$_SESSION[$type][] = $value;
}
function getAlerts()
{
$data = '';
foreach($this->alertTypes as $alert)
{
if (isset($_SESSION[$alert]))
{
foreach($_SESSION[$alert] as $value)
{
$data .= '<li class="'. $alert .'">' . $value . '</li>';
}
unset($_SESSION[$alert]);
}
}
return $data;
}
function error($type)
{
if($type == 'unauthorized')
{
$this->load(APP_PATH . 'core/views/v_unauthorized.php');
}
else
{
$this->load(APP_PATH . 'core/views/v_error.php');
}
}
}
答案 0 :(得分:0)
您需要将变量传递给class Template
中定义的error()函数:
function error($type){ ... }