TomPich Posted October 15, 2023 Share Posted October 15, 2023 Hello all, So I just finished my first website for a client using ProcessWire. That was a really nice experience and for now on, it will be my one and only CMS for professional purposes. I wonder why ProcessWire is not more used, considering that it is pure gold. I have two questions (I’ll ask the second one separately, as it’s not related to this one). Where to create a constant which will hold the version number of the website (to have a handy way to avoid .css and .js files caching problem) for best practice ? For now, I did it in the config.php file of the website (after all $config->xxx settings). Is there a smarter way to do this? Thanks again for your help. Link to comment Share on other sites More sharing options...
bernhard Posted October 15, 2023 Share Posted October 15, 2023 5 minutes ago, TomPich said: I wonder why ProcessWire is not more used, considering that it is pure gold. I think because there is nobody that cares about making it more popular. Which is a shame. And I think it's a little bit similar to linux. It's far more flexible, far more secure, but that also means that things are more complicated. There is no standard way of doing things and that's a problem. That means it's a lot harder to communicate and to learn. In windows or mac it's easy... Win10, 11... etc; MacBook Air / Pro ... Easy and everybody can understand that. Linux? Mint, Arch, Ubuntu, Suse etc etc... Which one to choose? Decide yourself. That's nice for someone who wants that freedom but it's a pain for 90% of "normal" users. So back to your question it's the same situation. There is no standard way of doing that in PW. You can (have to) find your own solution for it. It's easy. But there is no standard. I like to use timestamps of the file for cache busting. If you use RockFrontend that will be done automatically for you. If you want to read more about cache busting in the PW backend this issue has some interesting discussion: https://github.com/processwire/processwire-issues/issues/1791 And to give a simple solution to your actual question about where to put some constants: You could simply add that to config.php $config->version = "101"; And then append it to your assets like this: <link href="foo.css?v=<?= $config->version ?>" rel="stylesheet"> 1 Link to comment Share on other sites More sharing options...
TomPich Posted October 15, 2023 Author Share Posted October 15, 2023 Thanks Bernhard, Interesting comparison, with which I may not agree at 100%. In my opinion, you are comparing end users of OS, with devs. For end user, I think PW is at least as good as WP. It is simple and straight forward. But for devs, PW is so much simpler. You don’t have to struggle against stupid native functionalities with custom functions like in WP, or implements stuff that would really have to be part of the core (like opengraph tags or even simply a description to each page). I don’t even mention the endless updates, with every time the risk of breaking something. So for me, it’s just easier to develop on Processwire. And after only about 8-10 h of learning (far less than I needed to learn how to create a custom template in WP). Anyway, thanks for the tip. I didn’t know you could add class properties on the flight in PHP. That was my first thinking, but I didn’t even try it. And for the <link>, that is exactly my use case. ? Thanks again 1 Link to comment Share on other sites More sharing options...
bernhard Posted October 15, 2023 Share Posted October 15, 2023 1 hour ago, TomPich said: Anyway, thanks for the tip. I didn’t know you could add class properties on the flight in PHP. That was my first thinking, but I didn’t even try it. And for the <link>, that is exactly my use case. ? Yeah PW is very open here and PHP has been too. Since PHP 8.2 those dynamic properties are deprecated: https://php.watch/versions/8.2/dynamic-properties-deprecated Link to comment Share on other sites More sharing options...
TomPich Posted October 15, 2023 Author Share Posted October 15, 2023 Just a tip, it may be useful to someone : I tried to set $config->version in config.php (site folder), but, no matter what value I enter, I get Processwire version. So I defined $config->site_version, and it worked like a charm! Link to comment Share on other sites More sharing options...
bernhard Posted October 15, 2023 Share Posted October 15, 2023 Ah, sorry, that might have been a property that PW sets itself later in the process. Didn't know that as I'm using file modification timestamps as stated. Sorry for the confusion, but maybe good to see that one has to be careful with what you name your properties ? That's one of the downsides of allowing these kind of dynamic things I guess... Link to comment Share on other sites More sharing options...
TomPich Posted October 15, 2023 Author Share Posted October 15, 2023 Quote I'm using file modification timestamps Sounds like a good idea. I’ll have a look on how to do this. I have currently no idea. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now