I am trying to develop an extension (my_extension.php) that instead of outputting ($this->response->setOutput) to ...index.php?route=extension/analytics/my_extension it can, at the same time, output to any random URL or, at least, to more than one URL (my_extension_url_one, my_extension_url_two, etc).
Does anyone know how we can achieve that?
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
I suppose you mean "seo_url" for oc 3.x but that only "renames" the ugly route url, doesn't allow me to create different urls for 1 extension.paulfeakins wrote: ↑Mon Sep 30, 2019 7:00 pmYou should be able to add rows in the url_alias table to map any URL to your extension.
Essentially, I want to have multiple $this->response->setOutput to allow me to target different urls.
Other than "because I want to"?
I want the same extension to output different content to different pages so you can have, for example,
...index.php?route=extension/analytics/my_extension_products for product statistics
and
...index.php?route=extension/analytics/my_extension_categories for category statistics
Use a parameter like:
Code: Select all
index.php?route=extension/analytics/my_extension&output=categories
index.php?route=extension/analytics/my_extension&output=products
Code: Select all
RewriteRule ^(.*)/my-extension/(.*).html$ index.php?route=extension/analytics/my_extension&output=$2&%{QUERY_STRING} [NC]
Code: Select all
index.php?route=extension/analytics/my_extension/categories
index.php?route=extension/analytics/my_extension/products
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
For some reason it didn't occur to me to use parameters. Thanks!letxobnav wrote: ↑Tue Oct 01, 2019 10:02 amIf it is one extension outputting different content you have to tell the extension what to output.
Use a parameter like:Code: Select all
index.php?route=extension/analytics/my_extension&output=categories index.php?route=extension/analytics/my_extension&output=products
1. Adding an event:
---------
For the sake of testing, you can add event directly into database table oc_event with following information:
Code: Select all
code: my_extension
trigger: catalog/controller/extension/module/my_extension*/before
action: extension/module/my_extension/onRequest
---------------------
In your controller i.e catalog/extension/module/my_extension.php, add following method to process the event response:
Code: Select all
public function onRequest(&$route, $data) {
$this->request->get['action_to_be_taken'] = str_replace('extension/module/my_extension', '', $route);
$route = 'extension/module/my_extension';
}
XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart
That's helpful, thanks!
Because I'm a noob, does some list of events exists somewhere?
I'd be interested in tracking changes to products, categories, options, addresses, etc.
In your OC admin - > Extensions - > Events.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Users browsing this forum: Bing [Bot], Semrush [Bot] and 25 guests