Page 2 of 2

Re: Customizing headers for the twig views that use them in OC 3

Posted: Thu May 09, 2024 1:02 am
by straightlight
Lumirion wrote:
Thu May 09, 2024 12:17 am
Ok. Just as a test I switched the route back to the product page and replaced my str_replace with

Code: Select all

 $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 in line 65 of action.php. My css is not inserted into the product page either. Line 65 of action.php

Code: Select all

 $class = 'Controller' . preg_replace('/[^a-zA-Z0-9]/', '', $this->route); 
seems to be assembling the route to my insertproductpagestyles.php at admin/controller/extension/module/. $this->route seems to be returning null, so my controller is not referenced and my event handler is not called. Is there something wrong with either of these two addEvent lines?

Code: Select all

 $this->model_setting_event->addEvent('insertproductpagestyles', 'catalog/view/common/header/after', 'extension/module/insertproductpagestyles/addproductpagestyles'); 
and

Code: Select all

 $this->model_setting_event->addEvent('insertproductpagestyles', 'catalog/view/product/product/after', 'extension/module/insertproductpagestyles/addproductpagestyles'); 
Is it trying to look for my controller in catalog/controller/extension/module/ instead of in admin/controller/extension/module/ ?
Replace:

Code: Select all

$class = 'Controller' . preg_replace('/[^a-zA-Z0-9]/', '', $this->route); 
with:

Code: Select all

$class = 'Controller' . preg_replace('/[^a-zA-Z0-9]/', '', (string)$this->route); 
As for the rest of the Event controller of your extension, you haven't posted the changes.

Re: Customizing headers for the twig views that use them in OC 3

Posted: Thu May 09, 2024 5:56 am
by Lumirion
It is working. Thanks for all the help Straightlight. Here is a link to the zip. https://drive.google.com/file/d/1krWtC ... p=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 worked. I’ll tinker with the addStyle command later but for now this is solved.

Re: Customizing headers for the twig views that use them in OC 3

Posted: Thu May 09, 2024 6:48 am
by straightlight
Lumirion wrote:
Thu May 09, 2024 5:56 am
It is working. Thanks for all the help Straightlight. Here is a link to the zip. https://drive.google.com/file/d/1krWtC ... p=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 worked. I’ll tinker with the addStyle command later but for now this is solved.
Now that the issue has been resolved, please add: [SOLVED] at the beginning of the subject line on your first post.

Edit: And now you did. :)