覆盖WPMVC中的mvc_helper.php以修改WordPress中的默认表视图


Overwrite mvc_helper.php in WPMVC to modify the default table view in WordPress

我需要一个助手来更改wordpress中索引页面的默认视图。

我的插件是WPMVC生成的,根据WPMVC官方教程中的说明,我已经创建并加载了帮助程序,但它不起作用。

谁能告诉我正确的方法?

查看以下链接以获取屏幕截图。

https://i.stack.imgur.com/3a1Ao.png

在 screeshot 中,记录下方的链接和按钮由我添加,覆盖索引文件。

现在,我需要在"编辑 |查看 |删除图像中的",例如,

编辑 |查看 |添加规则 |删除

关于如何做到这一点的任何建议?

正如我之前所说,我创建并加载了帮助程序,但它不起作用。

需要帮助。谢谢。

代码:

/

app/helpers/geozone_helper.php (Create Helper(:

<?php 
class GeozoneHelper extends MvcHelper {
public $_redirect_action = '';
public function __construct() {
    if(empty($this->_redirect_action)) {
        $this->_redirect_action = 'geozone_rules-add';
    }       
    parent::__construct();
}
public function admin_actions_cell($controller, $object) {
    $links = array();
    $object_name = empty($object->__name) ? 'Item #'.$object->__id : $object->__name;
    $encoded_object_name = $this->esc_attr($object_name);
    $links[] = '<a href="'.MvcRouter::admin_url(array('object' => $object, 'action' => 'edit')).'" title="Edit '.$encoded_object_name.'">Edit</a>';
    $links[] = '<a href="'.MvcRouter::public_url(array('object' => $object)).'" title="View '.$encoded_object_name.'">View</a>';
    $links[] = '<a href="'.MvcRouter::admin_url(array('object' => $object, 'action' => $this->_redirect_action)).'" title="Edit '.$encoded_object_name.'">Add Rule</a>';
    $links[] = '<a href="'.MvcRouter::admin_url(array('object' => $object, 'action' => 'delete')).'" title="Delete '.$encoded_object_name.'" onclick="return confirm(&#039;Are you sure you want to delete '.$encoded_object_name.'?&#039;);">Delete</a>';
    $html = implode(' | ', $links);
    return '<td>'.$html.'</td>';
 }
}
/

app/controllers/geozones_controller.php (Load helper(:

public function show() {
    $object = $this->model->find_by_id($this->params['id'], array(
        'includes' => array('Geozone')));
    if (!empty($object)) {
        $this->set('object', $object);
        $this->render_view('show', array('layout' => 'public'));
    }
    $this->load_helper('geozone');
    $this->set_object();
}
/

app/view/geozones/show.php(链接到助手(:

 <h2><?php echo $object->__name; ?></h2>
 <p>
    <?php echo $this->html->link('&#8592; All Geozones', array('controller' =>   'geozones')); ?>
    <?php echo $this->geozone->admin_actions_cell($controller, $object->content); ?>
 </p>

再次感谢。

问题解决方式如下:函数

public function show() {
  $this->load_helper('geozone');
  $this->set_object();
}

在公共控制器中转移到管理控制器,函数名称更改为index((,如下所示:

public function index() {
  $this->load_helper('geozone');
  $this->set_objects();
}

感谢所有试图解决这个问题的人。