Post by kestas » Wed Dec 04, 2019 8:29 pm

stefg wrote:
Wed Dec 04, 2019 8:19 pm
BUT you could probably achieve the same effect with CSS only, so why add JS, edit the template etc.?
For example this works:

Code: Select all

#menu {
    /* Add */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
}
body {
    /* Add */
    padding-top: 43px;
}
[/quote]

Actually this code does not achieve the same result. It fixes the menu bar on top permanently.
[/quote]
Of course you not need edit menu.twig at all. You can add the piece of style to sylesheet.css, but the best way to create additional for example mystyle.css file where you'll add all your changes. And call it like stylesheet.css in header.twig. Because if you add to your main staylesheet.css you can lost your changes after reinstalling or upgrading OC. The same with js. You should create your own, for example mycommon.js, where you'll add your code. That's will be according standards.

Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am

Post by paulfeakins » Wed Dec 04, 2019 8:34 pm

kestas wrote:
Wed Dec 04, 2019 8:29 pm
You should create your own
Yes that's correct, you should create your own theme folder containing only the files that you have changed, and in this way no core OpenCart files will be modified.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Expert Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by OSWorX » Wed Dec 04, 2019 9:10 pm

paulfeakins wrote:
Wed Dec 04, 2019 8:08 pm
That's actually not what the third article you linked to says:
Image

So you can put it anywhere and it will work (with a flash of content) but it is still not best practice according to the standard and is advised against.
While this article is rather old, another answer from there (6td Dec 2018):
The HTML5.2 W3C Recommendation, 14 December 2017 (not the earlier draft referred to above) now says you can include <style>.

"In the body, where flow content is expected." (section 4.2.6)
The 3rd talk also about a scoped attribute - was never realized and dropped later.
Nevertheless, different solutions for same.
Just to mention: if a style is added into the HTML code (somewhere), a short "flash" (delay) may happen .. guess relevant only if you still use a 56k modem :laugh:

Custom Development | Individuelle Entwicklung | Support & Bugfixes

Image Image Image


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by paulfeakins » Wed Dec 04, 2019 11:33 pm

OSWorX wrote:
Wed Dec 04, 2019 9:10 pm
While this article is rather old, another answer from there (6td Dec 2018):
The HTML5.2 W3C Recommendation, 14 December 2017 (not the earlier draft referred to above) now says you can include <style>.

"In the body, where flow content is expected." (section 4.2.6)
Yes but the current HTML standard (as of today 4th Dec 2019) says:

Code: Select all

4.2.6 The style element
Categories:
    Metadata content.
Contexts in which this element can be used:
    Where metadata content is expected.
    In a noscript element that is a child of a head element.
There is an example of "metadata content" here and it is in the <head>.

This is in contrast to "3.2.5.2.2 Flow content" which is essentially the <body>.

If I am wrong I would be the first to thank you for improving my knowledge, but actually the HTML spec is clear where the <style> tag must be found.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Expert Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by stefg » Wed Dec 04, 2019 11:45 pm

In my case I like the script solution more that is changing the top menu when I scroll down the page.
However I don't know how to rework it and move the script from the twig file. As fore the style component I moved it to stylesheet.css. Thank you all for your comments.

New member

Posts

Joined
Fri Oct 18, 2019 7:25 pm

Post by paulfeakins » Wed Dec 04, 2019 11:48 pm

stefg wrote:
Wed Dec 04, 2019 11:45 pm
However I don't know how to rework it and move the script from the twig file.
Make a new folder in /catalog/view/theme/ and inside it add just your twig like this:
/catalog/view/theme/{your theme name}/{path to twig}/{twig name}

Then switch to {your theme name} in the admin.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Expert Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by stefg » Thu Dec 05, 2019 12:03 am

paulfeakins wrote:
Wed Dec 04, 2019 11:48 pm
stefg wrote:
Wed Dec 04, 2019 11:45 pm
However I don't know how to rework it and move the script from the twig file.
Make a new folder in /catalog/view/theme/ and inside it add just your twig like this:
/catalog/view/theme/{your theme name}/{path to twig}/{twig name}

Then switch to {your theme name} in the admin.
I have also made some changes in other original twig files. Currently I keep track of these changes by adding a note in the original twigs. Maybe I should gather all these changed file into one place as you suggest.

New member

Posts

Joined
Fri Oct 18, 2019 7:25 pm

Post by paulfeakins » Thu Dec 05, 2019 12:07 am

stefg wrote:
Thu Dec 05, 2019 12:03 am
I have also made some changes in other original twig files. Currently I keep track of these changes by adding a note in the original twigs. Maybe I should gather all these changed file into one place as you suggest.
That would be the correct way to do it.

You could:

1. Rename the default folder.
2. Add the default folder from a fresh download of your exact version.
3. In your renamed default folder, delete all files that you haven't edited and empty folders.

But be careful to take a backup of everything first as I would hate to advise you to do something that breaks your site and then requires a developer to charge you to fix.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Expert Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by by mona » Thu Dec 05, 2019 12:12 am

What you should do is write a simple OCMOD (or vQmod if that is what you use) to make the changes
Then you have all the changes recording in one place.

https://webocreation.com/blog/ocmod-documentation/

Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by paulfeakins » Thu Dec 05, 2019 12:16 am

by mona wrote:
Thu Dec 05, 2019 12:12 am
What you should do is write a simple OCMOD (or vQmod if that is what you use) to make the changes
Then you have all the changes recording in one place.

https://webocreation.com/blog/ocmod-documentation/
This is also a good way to do it.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Expert Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by stefg » Thu Dec 05, 2019 12:39 am

I make changes step by step in time, not all at once and they are in different areas. What about if I modify PHP files, currently I also track those changes with notes?

New member

Posts

Joined
Fri Oct 18, 2019 7:25 pm

Post by by mona » Thu Dec 05, 2019 1:09 am

This is why OCMOD / vQmod works so well.
You can edit it, delete and re-install - clear cache and its all updated in your modification folder.
Taking on-board Paul’s comments (which I missed when I posted) - this means that your modification files are the files which you can use as a hard copy of a new ‘theme’ logic - it will also keep a record of the files you have changed for the future - so future proof for an OC update.

This changes most files, including php and twig.
You can have one for each ‘area’ so you can keep a track of what each one does.
You can still add the notes to the OCMOD.

Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by stefg » Thu Dec 05, 2019 2:00 am

by mona wrote:
Thu Dec 05, 2019 1:09 am
This is why OCMOD / vQmod works so well.
You can edit it, delete and re-install - clear cache and its all updated in your modification folder.
Taking on-board Paul’s comments (which I missed when I posted) - this means that your modification files are the files which you can use as a hard copy of a new ‘theme’ logic - it will also keep a record of the files you have changed for the future - so future proof for an OC update.

This changes most files, including php and twig.
You can have one for each ‘area’ so you can keep a track of what each one does.
You can still add the notes to the OCMOD.
Currently before I modify an original file I make a copy of it and keep it in the same folder. In the modified file I track changes with notes. I managed to gather all modified twig files into a separate theme folder but cannot do this php files (is it also possible?).
I have not used OCMOD so far and rather hardcode changes instead because I do it step by step but I will check if it will be more convenient using OCMOD as you suggest. Thank you for your comments.

New member

Posts

Joined
Fri Oct 18, 2019 7:25 pm

Post by OSWorX » Thu Dec 05, 2019 5:13 am

paulfeakins wrote:
Wed Dec 04, 2019 11:33 pm
If I am wrong I would be the first to thank you for improving my knowledge, but actually the HTML spec is clear where the <style> tag must be found.
I never said that you are wrong - or did I?
But when we want to follow the "best" coding standards, we should talk with Daniel as soon as possible.
Because currently, in a few core files styles are embedded in the HTML section (one of them is the square payment extension).

Custom Development | Individuelle Entwicklung | Support & Bugfixes

Image Image Image


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by paulfeakins » Thu Dec 05, 2019 5:56 pm

OSWorX wrote:
Thu Dec 05, 2019 5:13 am
I never said that you are wrong - or did I?
I think we both agree <style> *should* be in the <head> but even so it will work everywhere, even if the W3C validator will show errors.

A point on OCMOD/vQmod - they will not allow you to modify JS files or CSS files, so in this case creating your own theme is probably the cleanest way.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Expert Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by kestas » Thu Dec 05, 2019 8:02 pm

paulfeakins wrote:
Thu Dec 05, 2019 5:56 pm

A point on OCMOD/vQmod - they will not allow you to modify JS files or CSS files, so in this case creating your own theme is probably the cleanest way.
Not true, JS files you can modify using OCMOD.
But the best way to create your own JS and CSS files and implement it to the right place using OCMOD or VQMOD.

Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am

Post by paulfeakins » Thu Dec 05, 2019 8:07 pm

kestas wrote:
Thu Dec 05, 2019 8:02 pm
Not true, JS files you can modify using OCMOD.
I don't think so but prove me wrong if you like and I'll eat my words.

kestas wrote:
Thu Dec 05, 2019 8:02 pm
But the best way to create your own JS and CSS files and implement it to the right place using OCMOD or VQMOD.
Nah, a new theme folder would be cleanest here.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Expert Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by stefg » Thu Dec 05, 2019 8:24 pm

What about original PHP files if I modify them, too. Which is the best way to track changes?

New member

Posts

Joined
Fri Oct 18, 2019 7:25 pm

Post by paulfeakins » Thu Dec 05, 2019 8:29 pm

stefg wrote:
Thu Dec 05, 2019 8:24 pm
What about original PHP files if I modify them, too. Which is the best way to track changes?
vQmod or OCMOD for those, don't touch the originals.

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Expert Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by stefg » Thu Dec 05, 2019 8:32 pm

paulfeakins wrote:
Thu Dec 05, 2019 8:29 pm
stefg wrote:
Thu Dec 05, 2019 8:24 pm
What about original PHP files if I modify them, too. Which is the best way to track changes?
vQmod or OCMOD for those, don't touch the originals.
Ok. Thanks a lot!

New member

Posts

Joined
Fri Oct 18, 2019 7:25 pm
Who is online

Users browsing this forum: No registered users and 15 guests