Post by DoctorDredd » Mon Aug 19, 2024 3:58 pm

Hello. I installed OpenCart Theme Example. Folder of theme example appeared in extensions.
I would like to use its controller - header.php and CSS files for new theme. I need just transfer file from controller/common folder to extension/oc_theme_example folder?

New member

Posts

Joined
Wed Jul 29, 2020 7:38 pm

Post by grgr » Tue Aug 20, 2024 8:11 am

No. It won't use a new ../controller/header.php in the extension folder.

-
Image Image Image
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK

Post by DoctorDredd » Tue Aug 20, 2024 1:28 pm

grgr wrote:
Tue Aug 20, 2024 8:11 am
No. It won't use a new ../controller/header.php in the extension folder.
OC4 uses only default controllers?
How to connect new styles or make changes in default controllers?

New member

Posts

Joined
Wed Jul 29, 2020 7:38 pm

Post by by mona » Tue Aug 20, 2024 3:47 pm

What made you think a template in OC4 is different from previous OC versions?
From what I understand from your post you have created an extension not a theme.
Themes are in extension extension themes and selected in settings

I am sure if you search google you will find other "tutorials", this seems pretty comprehensive (I have only had a quick glance) and it is for OC2, but the methodology is the same.
https://blog.templatetoaster.com/how-to ... art-theme/

1. You use css by using selectors and stylesheets.
2. You edit controllers with events for OC4, instead of ocmod in OC3 and OC2 and vqmod in OC1 and OC2 (and is still used in OC3 and OC4 although not globally)

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by DoctorDredd » Tue Aug 20, 2024 4:58 pm

by mona wrote:
Tue Aug 20, 2024 3:47 pm
What made you think a template in OC4 is different from previous OC versions?
From what I understand from your post you have created an extension not a theme.
Themes are in extension extension themes and selected in settings

I am sure if you search google you will find other "tutorials", this seems pretty comprehensive (I have only had a quick glance) and it is for OC2, but the methodology is the same.
https://blog.templatetoaster.com/how-to ... art-theme/

1. You use css by using selectors and stylesheets.
2. You edit controllers with events for OC4, instead of ocmod in OC3 and OC2 and vqmod in OC1 and OC2 (and is still used in OC3 and OC4 although not globally)
Thanks for link. I already went over some articles.

For theme in:
extension/theme/catalog/controller/startup/theme.php
need add common/header in:

Code: Select all

public function event(string &$route, array &$args, mixed &$output): void
    {
        $override = [
            'common/header',
        ];

        if (in_array($route, $override)) {
            $route = 'extension/theme/' . $route;
        }
    }
Then we can put the file header.twig in to extension/theme/catalog/view/template/common end edit it for changing a design.
For example if add common/footer code in startup controller and put footer.twig in to extension/theme/catalog/view/template/common, there will be possibility to change a design of footer.twig

According stylesheet.css:

Code: Select all

<link href="extension/webocreation4/catalog/view/stylesheet/stylesheet.css" type="text/css" rel="stylesheet"/>
There are two ways to change the stylesheet, events to change or directly add the code like above in to header.twig.

Looks like events very simple way to modify the code. I will discover more about all of that, thank you for helping I appreciate that!

New member

Posts

Joined
Wed Jul 29, 2020 7:38 pm

Post by DoctorDredd » Sun Aug 25, 2024 3:06 pm

Does anyone know how to override controllers correctly? I can't find the instructions unfortunately.

New member

Posts

Joined
Wed Jul 29, 2020 7:38 pm
Who is online

Users browsing this forum: No registered users and 4 guests