Post by nickpapoutsis » Mon Sep 30, 2019 7:45 am

Hey everyone,

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?

User avatar
New member

Posts

Joined
Mon Mar 25, 2019 7:49 am

Post by thekrotek » Mon Sep 30, 2019 12:19 pm

And what's the point of it?

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by paulfeakins » Mon Sep 30, 2019 7:00 pm

You should be able to add rows in the url_alias table to map any URL to your extension.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by nickpapoutsis » Tue Oct 01, 2019 5:54 am

paulfeakins wrote:
Mon Sep 30, 2019 7:00 pm
You should be able to add rows in the url_alias table to map any URL to your extension.
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.

Essentially, I want to have multiple $this->response->setOutput to allow me to target different urls.

thekrotek wrote:
Mon Sep 30, 2019 12:19 pm
And what's the point of it?
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

User avatar
New member

Posts

Joined
Mon Mar 25, 2019 7:49 am

Post by letxobnav » Tue Oct 01, 2019 10:02 am

If 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
Use in combination with htaccess rewrites like:

Code: Select all

RewriteRule ^(.*)/my-extension/(.*).html$ index.php?route=extension/analytics/my_extension&output=$2&%{QUERY_STRING} [NC]
so you can use:

Code: Select all

index.php?route=extension/analytics/my_extension/categories
index.php?route=extension/analytics/my_extension/products
something like that.

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.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by nickpapoutsis » Mon Oct 07, 2019 12:28 am

letxobnav wrote:
Tue Oct 01, 2019 10:02 am
If 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
For some reason it didn't occur to me to use parameters. Thanks!

User avatar
New member

Posts

Joined
Mon Mar 25, 2019 7:49 am

Post by opencartmart » Mon Oct 07, 2019 2:13 pm

You can use OC event. Here are the steps:

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
2. Adding Event Handler in your controller
---------------------
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';
    }
Now deliver your response depending on the GET variable `action_to_be_taken`

XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart


Active Member

Posts

Joined
Wed Oct 02, 2013 3:59 am

Post by nickpapoutsis » Sun Dec 22, 2019 10:07 pm

opencartmart wrote:
Mon Oct 07, 2019 2:13 pm
You can use OC event. Here are the steps:
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.

User avatar
New member

Posts

Joined
Mon Mar 25, 2019 7:49 am

Post by straightlight » Sun Dec 22, 2019 10:22 pm

On your database: <<table_prefix>>event table.

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


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: Bing [Bot] and 15 guests