Re: How do I access an array created by one controller in a second controller?
How would I get the event to dispatch between the 2 controllers? Can the event access the stored variables the twig file references?
Jump to post- Fri Oct 04, 2024 6:14 am
- Replies 6
- Views 686
How do I access an array created by one controller in a second controller?
Using Opencart 3.0.3.3. How do I access data, created by one controller, in a second controller? For instance, one controller generates the following object and makes it available to the view. $data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['n...
Jump to post- Thu Oct 03, 2024 11:32 pm
- Replies 6
- Views 686
Re: Is it possible to use OCMOD output as input in a triggered event?
Interesting. Do you know if the function "getTemplateBuffer" was pulled into Opencart by version 3.0.3.3? Otherwise I can copy it.
Jump to post- Tue Aug 20, 2024 11:15 pm
- Replies 5
- Views 477
Re: Is it possible to use OCMOD output as input in a triggered event?
I'm using a before event so I can access twig variables. hmm, I'm probably using PHP 7.4 then.
Jump to post- Tue Aug 20, 2024 6:04 am
- Replies 5
- Views 477
Is it possible to use OCMOD output as input in a triggered event?
I’m using: OC Version: 3.0.3.3 extension: Option Combinations PHP Version: 7.5 Option Combinations uses OCMOD to make changes to product.twig. But, when my event triggers I wind up fetching a clean copy of product.twig from the drive. Is there a way to check for a version that has been modified by O...
Jump to post- Tue Aug 20, 2024 2:03 am
- Replies 5
- Views 477
Re: Modifying header.twig with a before event
Well, at least I know my code works. That narrows it down. Must be some other conflicting extension or hackery going on and overriding my override. Time to reverse engineer an Opencart implementation. Thank you guys so much for all the help. I appreciate it.
Jump to post- Tue Jul 23, 2024 10:15 pm
- Replies 5
- Views 1332
Re: Any one know what would make DIR_CATALOG, that is clearly defined, throw Undefined Constant
Ah! Nice! We don't even have a catalog/config.php. That would explain it. When I get time I'll try and make one.
Jump to post- General Support
- [Solved] Any one know what would make DIR_CATALOG, that is clearly defined, throw Undefined Constant
- Tue Jul 23, 2024 10:06 pm
- Replies 8
- Views 1691
Re: Modifying header.twig with a before event
Interesting. I added the event logging code from your example and reinstalled my extension. I refreshed mods cache and opened a product page. Then checked the log. The log output was: 2024-07-19 10:44:57 - Before Common Header Event :: triggered 2024-07-19 10:44:57 - Before Common Header Event :: pr...
Jump to post- Sat Jul 20, 2024 12:18 am
- Replies 5
- Views 1332
Re: Modifying header.twig with a before event
Hello @softmonke. I am triggering on the view not the controller. 1. My event is registered and is displayed in Extensions>>Events. I believe the event is triggering but I don’t think my code is running in the event handler. I added a debug line that generates a text file containing the contents of ...
Jump to post- Fri Jul 19, 2024 10:46 pm
- Replies 5
- Views 1332
[Solved] Modifying header.twig with a before event
Previously, I made an extension that adds custom code to the header via an after event. Now I want to do the same but with a before event. For this one I am using Opencart 3.0.3.3. Now, when I did this with the after event, I was able to use if (isset($this->request->get['route']) && $this->...
Jump to post- Fri Jul 19, 2024 5:15 am
- Replies 5
- Views 1332
Re: Any one know what would make DIR_CATALOG, that is clearly defined, throw Undefined Constant
Thank you guys for the tips. @nonnedelectari , I located it in two config.php files though one appears to be a backup. Noted that the DIR_TEMPLATE has a different definition in config.php from the front end version of the define I'm using, as @JNeuhoff explained. I haven't located the file that defi...
Jump to post- General Support
- [Solved] Any one know what would make DIR_CATALOG, that is clearly defined, throw Undefined Constant
- Fri Jul 19, 2024 12:14 am
- Replies 8
- Views 1691
[Solved] Any one know what would make DIR_CATALOG, that is clearly defined, throw Undefined Constant
On an Opencart 3.0.3.3 server I keep running into an issue when I use the constant DIR_CATALOG. It keeps throwing: Warning: Use of undefined constant DIR_CATALOG - assumed 'DIR_CATALOG' (this will throw an Error in a future version of PHP) when ever I refer to it. I checked config.php and it is clea...
Jump to post- General Support
- [Solved] Any one know what would make DIR_CATALOG, that is clearly defined, throw Undefined Constant
- Thu Jul 18, 2024 3:06 am
- Replies 8
- Views 1691
Re: Customizing headers for the twig views that use them in OC 3
It is working. Thanks for all the help Straightlight. Here is a link to the zip. https://drive.google.com/file/d/1krWtCFjKlaGU6_oyulkazOElWq8JPfh9/view?usp=sharing Once I added a copy of the controller to the same location under the catalog path and switched back to editing the header str_replace wo...
Jump to post- Thu May 09, 2024 5:56 am
- Replies 22
- Views 18342
Re: Customizing headers for the twig views that use them in OC 3
Ok. Just as a test I switched the route back to the product page and replaced my str_replace with $this->document->addStyle('catalog/view/PDPStyles/productpage.css'); and added that css file with my styles in it. The result is the same error about preg_replace being passed a NULL as the third value ...
Jump to post- Thu May 09, 2024 12:17 am
- Replies 22
- Views 18342
Re: Customizing headers for the twig views that use them in OC 3
I’m using PHP 8.2 and Opencart 3.0.3.9 downloaded on 4/29/2024. Line 22 of insertproductpagesstyles.php, targeting the product page is commented out. Line 23 looks like this. $this->model_setting_event->addEvent('insertproductpagestyles', 'catalog/view/common/header/after', 'extension/module/insertp...
Jump to post- Wed May 08, 2024 12:37 am
- Replies 22
- Views 18342
Re: Customizing headers for the twig views that use them in OC 3
I made the changes we discussed. I changed the route registered in the event to 'catalog/view/common/header/after', and I modified the event handler like this. /* After product.twig is converted to HTML inject our CSS and styles into head */ public function addproductpagestyles(string &$route, a...
Jump to post- Tue May 07, 2024 6:01 am
- Replies 22
- Views 18342
Re: Customizing headers for the twig views that use them in OC 3
Thank you. Ill switch to modifying the header and use
Code: Select all
$this->request->get['route']
- Mon May 06, 2024 10:36 pm
- Replies 22
- Views 18342
Re: Customizing headers for the twig views that use them in OC 3
Good point about removing the underscores and capitalization in my routes and filenames. I will rename the files and update routes and fix the twig syntax shortly. Now about my product page route, I’m trying to edit the head only when it’s being used for a product page. I don’t think that, if I use ...
Jump to post- Sat May 04, 2024 3:40 am
- Replies 22
- Views 18342
Re: Customizing headers for the twig views that use them in OC 3
Yes, I used the installer. Here is a copy of the zip. https://drive.google.com/file/d/1QN76K ... p=sharing
Jump to post- Fri May 03, 2024 10:37 pm
- Replies 22
- Views 18342
Re: Customizing headers for the twig views that use them in OC 3
I created a clean testing environment by installing the latest 3.0.3.9 version of OpenCart on a Virtual machine. Then I made a basic module and tested whether it would install on the server. I removed the module and edited it to register an event and handle it like this: public function install() { ...
Jump to post- Fri May 03, 2024 4:13 am
- Replies 22
- Views 18342