Does anybody know view file code like we do in Ocmod ?
for example this is view code:
{% for store in stores %}
<a href="{{ store.href }}" target="_blank" class="dropdown-item">{{ store.name }}</a>
{% endfor %}
with ocmod we can set search string
<a href="{{ store.href }}" target="_blank" class="dropdown-item">{{ store.name }}</a>
and replace with
<a href="{{ store.href }}" target="_blank" class="dropdown-item store-{{ store.id }}">{{ store.name }}</a>
Download sample ocmod.zip in this link.
https://www.codinginspect.com/test/modi ... .ocmod.zip
do not install this ocmod file on opencart store. it is only demonstration purpose only. To acheive same out with event system.
Does anybody know how we can acheive the same event system ?
for example this is view code:
{% for store in stores %}
<a href="{{ store.href }}" target="_blank" class="dropdown-item">{{ store.name }}</a>
{% endfor %}
with ocmod we can set search string
<a href="{{ store.href }}" target="_blank" class="dropdown-item">{{ store.name }}</a>
and replace with
<a href="{{ store.href }}" target="_blank" class="dropdown-item store-{{ store.id }}">{{ store.name }}</a>
Download sample ocmod.zip in this link.
https://www.codinginspect.com/test/modi ... .ocmod.zip
do not install this ocmod file on opencart store. it is only demonstration purpose only. To acheive same out with event system.
Does anybody know how we can acheive the same event system ?
You could either take a look on the latest OC v3.x release in your catalog/controller/extension/advertise/google.php file on how to use a /after event or use an extension from the Marketplace. Alternatively, you could see this topic: viewtopic.php?f=144&t=227710#p839437codinginspect wrote: ↑Fri May 27, 2022 9:15 pmDoes anybody know view file code like we do in Ocmod ?
for example this is view code:
{% for store in stores %}
<a href="{{ store.href }}" target="_blank" class="dropdown-item">{{ store.name }}</a>
{% endfor %}
with ocmod we can set search string
<a href="{{ store.href }}" target="_blank" class="dropdown-item">{{ store.name }}</a>
and replace with
<a href="{{ store.href }}" target="_blank" class="dropdown-item store-{{ store.id }}">{{ store.name }}</a>
Download sample ocmod.zip in this link.
https://www.codinginspect.com/test/modi ... .ocmod.zip
do not install this ocmod file on opencart store. it is only demonstration purpose only. To acheive same out with event system.
Does anybody know how we can acheive the same event system ?
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Hi
I'm not sure if this is a smart way or not, but I tested it and it works.
Note that I did this test with OpenCart version 3.0.2.0.
Event code: test
Event trigger: admin/view/common/header/after
Event action: extension/module/test
admin\controller\extension\module\test.php
In this example instead of adding a class store-{{ store.id }} I added a new attribute data-store-id.
I'm not sure if this is a smart way or not, but I tested it and it works.
Note that I did this test with OpenCart version 3.0.2.0.
Event code: test
Event trigger: admin/view/common/header/after
Event action: extension/module/test
admin\controller\extension\module\test.php
Code: Select all
<?php
class ControllerExtensionModuleTest extends Controller {
public function index($route = '', $data = array(), &$output = '') {
$stores = array();
$stores[] = array(
'name' => $this->config->get('config_name'),
'href' => HTTP_CATALOG,
'store_id' => 0
);
$this->load->model('setting/store');
$results = $this->model_setting_store->getStores();
foreach ($results as $result) {
$stores[] = array(
'name' => $result['name'],
'href' => $result['url'],
'store_id' => $result['store_id']
);
}
foreach ($stores as $store) {
$output = str_replace('href="' . $store['href'] . '"', 'href="' . $store['href'] . '" data-store-id="' . $store['store_id'] . '"', $output);
}
}
}
This has been discussed several times on the OpenCart forum, see e.g. viewtopic.php?f=144&t=221533 on how to a view/*/before event handler for modifying a template.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
The parameters are not added correctly. Referenced variables without the need to affect the types of variables can simply be used.DigitCart wrote: ↑Mon May 30, 2022 3:38 amHi
I'm not sure if this is a smart way or not, but I tested it and it works.
Note that I did this test with OpenCart version 3.0.2.0.
Event code: test
Event trigger: admin/view/common/header/after
Event action: extension/module/test
admin\controller\extension\module\test.phpIn this example instead of adding a class store-{{ store.id }} I added a new attribute data-store-id.Code: Select all
<?php class ControllerExtensionModuleTest extends Controller { public function index($route = '', $data = array(), &$output = '') { $stores = array(); $stores[] = array( 'name' => $this->config->get('config_name'), 'href' => HTTP_CATALOG, 'store_id' => 0 ); $this->load->model('setting/store'); $results = $this->model_setting_store->getStores(); foreach ($results as $result) { $stores[] = array( 'name' => $result['name'], 'href' => $result['url'], 'store_id' => $result['store_id'] ); } foreach ($stores as $store) { $output = str_replace('href="' . $store['href'] . '"', 'href="' . $store['href'] . '" data-store-id="' . $store['store_id'] . '"', $output); } } }
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Who is online
Users browsing this forum: No registered users and 48 guests