(!)致命错误:require():在第265行打开所需的''/ mvc_controller.php
尽管在论坛,stackexchange等中尝试了这么多建议,但我得到了上述错误。
我正在使用WP MVC在WordPress 4.0.1中开发一个插件,它还封装了使用WP MVC内置的ORM概念。我无法找到解决方案。
以下是代码: (公共控制人)
/app/controllers/geozone_rules_controller.php
<?php
class GeozoneRulesController extends MvcPublicController {
var $after = array('set_geozonerules');
public function set_geozonerules() {
$this->load_model('GeozoneRule');
$geozonerules = $this->GeozoneRule->find();
$this->set('geozonerules', $geozonerules);
}
// Overwrite the default index() method to include the 'is_public' => true condition
public function index() {
$objects = $this->GeozoneRule->find(array(
'joins' => array('Geozone', 'Country', 'Zone'),
'includes' => array('Geozone', 'Country', 'Zone'),
'selects' => array('Geozone.id, Geozone.geozone_name',
array('Country.id, Country.country_name',
array('Zone.id', 'Zone.zone_name',
array('GeozoneRule.id', 'GeozoneRule.ordering')
)
)))
);
$this->set('objects', $objects);
// pagination
$this->params['page'] = empty($this->params['page']) ? 1 : $this->params['page'];
$this->params['conditions'] = array('is_public' => true);
$collection = $this->model->paginate($this->params);
$this->set('objects', $collection['objects']);
$this->set_pagination($collection);
echo '<a href="admin.php?page=mvc_geozone_rules-add">Add New Geozone Rule</a>';
}
// GeozoneRule selects only GeozoneRule names and ids by default; to select all fields from GeozoneRule,
// we'll overwrite the default show() method
public function show() {
$object = $this->model->find_by_id($this->params['id'], array(
'includes' => array(
'Geozone',
'Country',
'Zone',
'GeozoneRule' => array(
'selects' => 'GeozoneRule.*'
)
)
));
if (!empty($object)) {
$this->set('object', $object);
$this->render_view('show', array('layout' => 'public'));
}
}
}
?>
型号:
<?php
class GeozoneRule extends MvcModel {
var $table = '{prefix}w2store_geozonerules';
var $primary_key = 'id';
var $display_field = 'id';
var $default_order = 'sort_name';
var $includes = array('Geozone', 'Country', 'Zone');
var $has_and_belongs_to_many = array(
'GeozoneRule' => array(
'join_table' => array('{prefix}w2store_geozones',
'fields' => array('id', 'geozone_name')),
array('{prefix}w2store_countries',
'fields' => array('id', 'country_name')),
array('{prefix}w2store_zones',
'fields' => array('id', 'zone_name')),
'fields' => array('id', 'ordering')
)
);
public function after_find($object) {
if (isset($object->geozonerules)) {
$geozonerule_names = array();
foreach($object->geozonerules as $geozonerule) {
$geozonerule_names[] = $geozonerule->name;
}
}
// print_r ($object);
// exit;
}
public function after_save($object) {
$this->update_sort_name($object);
}
public function update_sort_name($object) {
$sort_name = $object->geozonerule_name;
$this->update($object->__id, array('sort_name' => $sort_name));
}
}
?>
现在我得到了错误:
Warning: require(): Filename cannot be empty in /mvc_controller.php
第265行调用堆栈 时间记忆功能位置。 。 11 0.0659 3870616
任何可能的解决方案都会有很大帮助。非常感谢。
答案 0 :(得分:0)
问题解决了。简单的错误引起了很多大惊小怪。
在views / admin /文件夹中,名称&#39; geozonerules&#39;中有一个模型GeozoneRule的文件夹。它被重命名为&#39; geozone_rules&#39;。现在没关系。
需要特别注意文件夹和文件的命名。
谢谢大家。