Post by madox » Sat May 26, 2018 12:52 pm

i edit the code at catalog/controller/extension/ but the file i edit dont have any effect at frontend, even if i del all the code
for example i write a code $data['abcd']="DDD"; to test the source
but at twig theme i write {{abcd}} dont have any respone
but i del the file will display error
may i know what happen?

Newbie

Posts

Joined
Sat May 26, 2018 10:12 am

Post by darioush3 » Sun May 27, 2018 4:21 pm

hello
could you copy and paste the code or send a screen shot of error?

Newbie

Posts

Joined
Sun May 27, 2018 4:18 pm

Post by acx » Mon May 28, 2018 12:48 pm

Editing the controller alone does not pass data to the front-end; the controller passes data. You then have to call the data the controller is passing.

Say you make the change in your controller, like so:

Code: Select all

$data['mytest'] = 'this is my test';
You have to edit the corresponding template file (aka 'the view' part of MVC) to call it:

Code: Select all

<?php echo $mytest; ?>
To know what view file to edit, you can either (in most cases) assume it's the corresponding path of the controller file you're editing:
Controller: admin/controller/common/header.php
View: /admin/view/template/common/header.tpl

or consult the function you're currently editing, inside the controller:

If you're editing the following function in header.php:

Code: Select all

public function index() {
Look for the closure of this function, it will have a line like this:

Code: Select all

return $this->load->view('common/header', $data);
..which tells us the template file is common/header.

The framework automatically fills the file path (/admin/view/template/common/header.tpl) -- the surriounding filepath is always consistent. so when you're looking at the $this->load->view you can always 'fill in the blanks' with view/template/common/header.tpl

Extensions I've made (free):

Breadcrumbs for 2.3.0.2 & 3.0.2.0 Breadcrumb links for subcategories & parent category on product pages
Product Requests Allow customers to request notifications for sold out products
Abandoned Carts Send inquiries to abandoned carts to complete checkout or provide feedback
Ghost Orders Cleanup residue left behind by one page checkout addons


acx
New member

Posts

Joined
Wed Mar 21, 2018 8:39 am

Who is online

Users browsing this forum: No registered users and 3 guests