Hash values for custom CSS files

For support and discussion related to templates and themes in phpBB 3.3.
User avatar
KaileyT
Community Team Member
Community Team Member
Posts: 2899
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Hash values for custom CSS files

Post by KaileyT »

Since 3.3.1 uses hash values in stylesheet.css, how should we generate hash values if we want to include a custom.css file?
Kailey Truscott - Community Team
User avatar
_Vinny_
Style Customisations
Style Customisations
Posts: 8783
Joined: Tue Aug 11, 2009 12:45 am
Location: Brazil
Name: Marcus Vinicius
Contact:

Re: Hash values for custom CSS files

Post by _Vinny_ »

In a very quick way, you can use the 7-zip to see the value.
User avatar
3Di
Former Team Member
Posts: 16091
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano 🇮🇹 Frankfurt 🇩🇪
Name: Marco
Contact:

Re: Hash values for custom CSS files

Post by 3Di »

$hash = sprintf('%08x', crc32(file_get_contents('my_css_file')));
https://github.com/phpbb/phpbb/pull/601 ... af38946R43

Though I don't think you have to do that.
Last edited by 3Di on Fri Aug 07, 2020 10:40 pm, edited 2 times in total.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
AbaddonOrmuz
Recognised Extension Developer
Posts: 1047
Joined: Wed Dec 25, 2013 9:06 pm
Location: /dev/null
Name: Alfredo
Contact:

Re: Hash values for custom CSS files

Post by AbaddonOrmuz »

It's a crc32 file checksum, although you could use any other algorithm (sha256, sha512, etc) and cut the length.

In GNU/Linix or Unix systems you could do the following:

Code: Select all

sha1sum -b custom.css | cut -c 1-8
Although you could put an arbitrary string.
Some of my phpBB extensions:
Image Imgur | :chart_with_upwards_trend: SEO Metadata | Image Markdown | :lock: Auto-lock Topics
:trophy: Check out all my validated extensions :trophy:

:penguin: Arch Linux user :penguin:
User avatar
PlanetStyles.net
Former Team Member
Posts: 4714
Joined: Wed Nov 04, 2009 11:16 pm
Location: UK
Name: Christian
Contact:

Re: Hash values for custom CSS files

Post by PlanetStyles.net »

AbaddonOrmuz wrote:
Fri Aug 07, 2020 10:39 pm
Although you could put an arbitrary string.
^ This.

Anyone reading this thread shouldn't feel obliged to over-complicate this and replicate phpBB's approach of using checksums. The idea is that when the file's updated, the asset version is also updated in the file path - which forces the browser to re-download that asset and 'replace' whatever's cached.

If you're not making edits particularly frequently, you can just as easily use something like the date you changed the file (eg: ?v=08082020), or some other random thing you can think of (eg: ?v=megacoolupdate1).

You can also live without asset versioning completely, but users will need to clear cache when you update the file.
User avatar
KaileyT
Community Team Member
Community Team Member
Posts: 2899
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Hash values for custom CSS files

Post by KaileyT »

_Vinny_ wrote:
Fri Aug 07, 2020 10:33 pm
you can use the 7-zip to see the value
Thanks, was able to find it very easily.
PlanetStyles.net wrote:
Sat Aug 08, 2020 12:16 am
Anyone reading this thread shouldn't feel obliged to over-complicate this and replicate phpBB's approach of using checksums.
I understand the asset versioning aspect, but I like to follow phpBB's approach. It's a quick I've had ever since I started using the software.

Thank you for all the replies everyone, they are much appreciated! :)
Kailey Truscott - Community Team
User avatar
Mannix_
Registered User
Posts: 1014
Joined: Sun Oct 25, 2015 2:56 pm
Name: Matt
Contact:

Re: Hash values for custom CSS files

Post by Mannix_ »

What about the css files that have been included in the overall_header.html file?
-=-=-=-=-=-=-=-=-=-=-=-=-My Styles-=-=-=-=-=-=-=-=-=-=-=-=-
HexagonHexagonRebornCleanSilverProject Durango
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Need help with styling or want me to port a style to 3.3.x etc. contact me here or here.
New version of phpBB has been released? My styles aren't validated for it yet? Check my page for the latest downloads!
User avatar
DTMWC
Registered User
Posts: 375
Joined: Tue Jan 16, 2018 6:17 am

Re: Hash values for custom CSS files

Post by DTMWC »

Ooo this looks messy, beyond the scope of my realm, I retire from styles and put more time into my homebrew lockdown hobby in the garage while listening to reggae and playing Brian Lara cricket.
If you use CodePen... Give @SMKS's Thank You NHS pen a like.
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 4259
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.
Contact:

Re: Hash values for custom CSS files

Post by thecoalman »

Mannix_ wrote:
Sat Aug 08, 2020 10:07 am
What about the css files that have been included in the overall_header.html file?
When you purge the cache or other actions like updating the version is incremented, in this case 123.

<link href="./styles/prosilver/theme/stylesheet.css?assets_version=123" rel="stylesheet">

It's considered new file so the browser will download it. The issue is stylesheet.css is static file and will contain import links for other CSS files like this:

@import url("normalize.css?hash=e6c08715");

Since they are using hash value it will change if the file is changed. This only applies to updates though.... If you edit any of these files between updates you need to edit the value hash=but it could be anything.

Purge the cache which will trigger the browser to download new version of stylesheet.css and it will also download new version of any files you have changed value for hash=.
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
User avatar
PlanetStyles.net
Former Team Member
Posts: 4714
Joined: Wed Nov 04, 2009 11:16 pm
Location: UK
Name: Christian
Contact:

Re: Hash values for custom CSS files

Post by PlanetStyles.net »

Dan Stylez wrote:
Sun Aug 09, 2020 10:52 am
Ooo this looks messy, beyond the scope of my realm, I retire from styles and put more time into my homebrew lockdown hobby in the garage while listening to reggae and playing Brian Lara cricket.
No need to use hash values. You can go back to using (?v=3.3) if you want, or anything else.
User avatar
Joyce&Luna
Registered User
Posts: 290
Joined: Wed Oct 14, 2015 3:46 pm
Location: Germany
Name: Anke
Contact:

Re: Hash values for custom CSS files

Post by Joyce&Luna »

Hash is specified in the style changes.
I don't think the style will be validated without this hash.

Do you have to determine a new hash every time you change the style?
As you do when supporting the styles, do I have to give everyone a hash?
So I think it's really hard and you really lose the desire to do something there.
My contributions are translated from German to English by google. This can lead to misunderstanding.

phpBB Style Design
User avatar
Mannix_
Registered User
Posts: 1014
Joined: Sun Oct 25, 2015 2:56 pm
Name: Matt
Contact:

Re: Hash values for custom CSS files

Post by Mannix_ »

thecoalman wrote:
Sun Aug 09, 2020 11:56 am
Thank you for the clarification :)
-=-=-=-=-=-=-=-=-=-=-=-=-My Styles-=-=-=-=-=-=-=-=-=-=-=-=-
HexagonHexagonRebornCleanSilverProject Durango
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Need help with styling or want me to port a style to 3.3.x etc. contact me here or here.
New version of phpBB has been released? My styles aren't validated for it yet? Check my page for the latest downloads!
User avatar
Scanialady
Registered User
Posts: 361
Joined: Thu Jan 17, 2013 7:09 pm
Location: Germany
Name: Annette
Contact:

Re: Hash values for custom CSS files

Post by Scanialady »

Mannix_ wrote:
Sat Aug 08, 2020 10:07 am
What about the css files that have been included in the overall_header.html file?
Is there an answer?
Webseite, Blog, Wiki Deutsche Übersetzungen - german language files
My 2 cents: Whether an extension is in the CDB says nothing about its quality. It is more important to read the support topics for it. Better to avoid authors who do not answer support questions themselves, who do not update their stuff, and who do not fix bugs for years.
User avatar
wintstar
Registered User
Posts: 329
Joined: Sat Mar 07, 2009 12:39 pm

Re: Hash values for custom CSS files

Post by wintstar »

I think that with the new function css files to hash the end of many styles will. Have you developers thought about how much effort style authors have to give support for css hash :?

Free time is a precious commodity. Not everyone wants to spend it with hashing css files.
Regards wintstar

There are people who say I have no idea what I'm writing about, and I don't understand anything. Let them write, because they look in the mirror and write about their own selves.
My board - My atelier - Css Hash Tool - Memories of phpBB 3.0.14
User avatar
JoshyPHP
Code Contributor
Posts: 1196
Joined: Mon Jul 11, 2011 12:28 am

Re: Hash values for custom CSS files

Post by JoshyPHP »

wintstar wrote:
Sun Aug 09, 2020 7:12 pm
Free time is a precious commodity.
Let me save you some time. Pretty much everything you posted is wrong so you should just log out and forget about it.
I wrote the thing that does BBCodes in 3.2+.
Post Reply

Return to “[3.3.x] Styles Support & Discussion”