Overwrite mvc_helper.php in WPMVC to modify the default table view in WordPress
-
I need a helper to change the default view of index page in wordpress.
My plugin is WPMVC generated and as per instructions in the official tutorial of WPMVC, i have created and loaded the helper but it is not working.
Can any one show me the right way to proceed?
![index.php of geozones][1]
[1]: https://i.stack.imgur.com/3a1Ao.png
In the above image, the links and button below the records are added by me, overwriting the index file.
Now, i need to add a link near ‘Edit | View | Delete’ in the image, like,
Edit | View | Add Rule | Delete
Any suggestions on how to do that?
As i have told earlier, i created and loaded the helper but it is not functioning.
Need help. Thanks.
Codes:
/w2-store/app/helpers/geozone_helper.php (Create Helper): <?php class GeozoneHelper extends MvcHelper { public $_redirect_action = ''; public function __construct() { 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('Are you sure you want to delete '.$encoded_object_name.'?');">Delete</a>'; $html = implode(' | ', $links); return '<td>'.$html.'</td>'; } }
/w2-stores/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(); }
/w2-store/app/view/geozones/show.php (link to the helper): <h2><?php echo $object->__name; ?></h2> <p> <?php echo $this->html->link('← All Geozones', array('controller' => 'geozones')); ?> <?php echo $this->geozone->admin_actions_cell($controller, $object->content); ?> </p>
Thanks a lot again.
- The topic ‘Overwrite mvc_helper.php in WPMVC to modify the default table view in WordPress’ is closed to new replies.