adrian Posted February 19, 2014 Share Posted February 19, 2014 Not sure what you mean. I just put all my scripts inside /site/templates/scripts/ Sorry, I probably wasn't very clear on that - I am talking about php scripts that need to be called from the browser, but that are not PW template files. For example this could be an AJAX call to a php file. That make sense now? To clarify, any javascript files can definitely be run from inside templates/scripts. Sorry for the confusion. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted February 19, 2014 Share Posted February 19, 2014 We need the old technic here: Post some clumsy text. After that -> edit the post. (then you're first one that responded ) Link to comment Share on other sites More sharing options...
kongondo Posted February 19, 2014 Share Posted February 19, 2014 Hehe...what I'd want is a notification/or marked as unread if a post has been edited ....I don't think that is possible at the moment, no? Link to comment Share on other sites More sharing options...
MikeB Posted February 19, 2014 Share Posted February 19, 2014 Guys, thanks very much for the very quick responses. I get now why there is no predefined way to organize things, and understanding that will help. I think the rest will come with time. Guess I am just not used to having this much control. You have all been very helpful. Thanks again. Link to comment Share on other sites More sharing options...
Joss Posted February 19, 2014 Share Posted February 19, 2014 It might be worth you just doing one of the easy tutorials - they are a bit like being taught to suck eggs (sorry, I tend to write like that) but they will give you a good idea of how to think your way through the process. Again, they are just one way of doing things, but they are very clear. http://wiki.processwire.com/index.php/Category:Long_Tutorials The basic website tutorial is as a good a place as any. Link to comment Share on other sites More sharing options...
Joss Posted February 19, 2014 Share Posted February 19, 2014 Oh, one little tip if you like using JQuery plugins. The default PW installation comes with Styles and Scripts folders inside of templates. However, a lot of frameworks and JS plugins use css and js as folder names. When I start a new PW project, the first thing I do is change the names to css and js - I get less puzzling surprises that way! 2 Link to comment Share on other sites More sharing options...
MikeB Posted February 19, 2014 Share Posted February 19, 2014 Already done that one . Thanks. Link to comment Share on other sites More sharing options...
DaveP Posted February 20, 2014 Share Posted February 20, 2014 Guess I am just not used to having this much control. Exactly my own thoughts when I first discovered PW. 'It can't be that easy.' (I came from a mostly Mambo/Joomla & Wordpress background and found it unbelievable that a CMS existed that didn't enforce rigid field & template structures on the user.) 3 Link to comment Share on other sites More sharing options...
pwired Posted February 20, 2014 Share Posted February 20, 2014 Guess I am just not used to having this much control. That's what I am still struggling with. Having worked before with a lot of other cms'es and wysiwygets and then all of a sudden all the rules and walls fall away. You have to step over old thinking, habits and routines. There's also self coding and php that gets in what you need to learn. 3 Link to comment Share on other sites More sharing options...
Beluga Posted July 20, 2014 Share Posted July 20, 2014 Let's deprecate PSR-0 already http://philsturgeon.uk/blog/2014/07/deprecate-psr0 Link to comment Share on other sites More sharing options...
dragan Posted July 20, 2014 Share Posted July 20, 2014 Code MUST use 5 spaces for indenting on Mac, 3 for Linux and 3.5 on Windows. This a applies to the developer not the file - so there will be various different indents as different developers on different operating systems work in the same file. This will help define accountability of code. 2 Link to comment Share on other sites More sharing options...
tpr Posted November 26, 2015 Share Posted November 26, 2015 The style guide is here: https://processwire.com/api/coding-style-guide/ However, I don't get why are double quotes recommended for strings echoed here: https://processwire.com/api/coding-style-guide/#8.1-single-vs-double-quotes Doing so will result in such html: <link rel='stylesheet' media='screen' href='style.css'> Which is perfectly valid but in most cases double quotes are used for html tags - at least I think so. Following the style guide will likely result in mixed html quotes on a site. I also see that variables may be easier to add if the string is encapsulated in double quotes. However, editors and IDEs can higlight variables better if they are concatenated, and they are easier to spot. Just asking. Link to comment Share on other sites More sharing options...
Pete Posted November 26, 2015 Share Posted November 26, 2015 Editors like PHPStorm (which I know a few here use) will highlight variables the same however you use quotes, so shouldn't be any harder to spot. I know Ryan uses PHPStorm and so do several others here but not sure if other editors cause variables to be less noticeable? 1 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted November 26, 2015 Share Posted November 26, 2015 There are a few advantages using double quotes for strings. It's not uncommon that sentences have single quotes like this sentence. When sticking to double quotes it is more unlikely that you have to change your quoting style and get mixed quotings styles. Next variables are processed in double quotes. I prefer writing PHP containing HTML above HTML containing PHP. So the single quote HTML tags makes perfectly sense to me. 1 Link to comment Share on other sites More sharing options...
tpr Posted November 26, 2015 Share Posted November 26, 2015 I see your points, thanks. I also use PhpStorm and yes, variables are highlighted in such cases too. Consider this: $editUrl = "data-mfp-src='{$page->editUrl}$lang&modal=1'"; $editUrl = 'data-mfp-src="' . $page->editUrl . $lang . '&modal=1"'; The first will result in single quote html tags and it is less readable imho. The second results in double quotes and for me it's more readable and separated. The first will most likely cause mixed quotes in html tags if you view the whole site's source. I know it's not a big deal but it doesn't seem logical to me. One should write single quotes for html tags in all his template files to avoid mixed quotes. Of course this is only my opinion, perhaps because I'm coming from the front-end side. Link to comment Share on other sites More sharing options...
kongondo Posted November 26, 2015 Share Posted November 26, 2015 It is RECOMMENDED that you use variables embedded in strings, when possible, rather than concatenating multiple strings. Double quotes must be used to embed variables in strings. It is a recommendation (and for good reason...performance-wise [Google it] ).....but, personally, I almost always use your '2nd' example $editUrl = 'data-mfp-src="' . $page->editUrl . $lang . '&modal=1"'; ...for readability.... as long as there is no performance hit... 1 Link to comment Share on other sites More sharing options...
tpr Posted November 26, 2015 Share Posted November 26, 2015 I know it's only a recommendation but wanted to know if there's a reason that I'm missing. (seems no) I've set up the PHP coding style in PhpStorm according to the style guide and almost everything was similar as my personal preference, except the quotes (partly). Link to comment Share on other sites More sharing options...
LostKobrakai Posted November 26, 2015 Share Posted November 26, 2015 Html does not care about which quotes are used and from the php standpoint it's more useful to go with double quotes to have the ability to insert variables directly. If that doesn't fit your style you can still use explicit concatination. Html 5 doesn't even need quote in lot's of arguments anymore and I really cannot remember the last time I actually looked at raw source code. All the dev tools automatically convert quotes to the double ones so I'm not sure why inconsistancy in the html result would matter. Edit: Not to mention, that this style guide is meant for the core development, where probably 80% of the code aren't related to html. Link to comment Share on other sites More sharing options...
Macrura Posted November 26, 2015 Share Posted November 26, 2015 you could also escape double quotes, if you're not following the style guide explicitly and wish to have double quotes on the output Link to comment Share on other sites More sharing options...
teppo Posted November 27, 2015 Share Posted November 27, 2015 The first will result in single quote html tags and it is less readable imho. The second results in double quotes and for me it's more readable and separated. The first will most likely cause mixed quotes in html tags if you view the whole site's source. I know it's not a big deal but it doesn't seem logical to me. One should write single quotes for html tags in all his template files to avoid mixed quotes. Your preference towards double quotes in HTML markup is purely visual. The browser doesn't care, users won't care, and if you enable minification via something like ProCache, it's actually possible that it might automatically remove some of those quotes altogether. In many cases the quotes are not needed at all, which means that they're just taking extra space. Regardless, my personal preference in PHP is to always use single quotes by default, and double quotes only if I really want to embed variables in the string. Using single quotes means that there's zero chance of accidentally inserting a variable, or really any string starting with dollar sign that would be interpreted as one. When I do want variables in the string, I prefer double quotes, though I also tend to use curly braces everywhere, regardless of whether they're "necessary": $editUrl = "data-mfp-src='{$page->editUrl}{$lang}&modal=1'"; Regarding editors: my opinion is that any decent editor should get highlighting right. If your preferred editor doesn't, consider switching. If syntax highlighting works in some cases, but not always, that's a potential source of confusion. In the end the style guide for ProcessWire is no different from other style guides in that many things there are opinion-based. If you don't want to use that in your own projects, you don't have to, but of course adhering to it could make working together with fellow ProcessWire users slightly easier. Link to comment Share on other sites More sharing options...
mr-fan Posted November 27, 2015 Share Posted November 27, 2015 one of the best resource on this topic: http://nikic.github.io/2012/01/09/Disproving-the-Single-Quotes-Performance-Myth.html general more simple stats on what PHP handling has impact on speed: http://phpbench.com/ regards mr-fan ...'i'.'like'.'this'.'style'.'too'.'but'.'it'.'seems'.'that'.'in'.'fact'.'it'.'is'.'slower'.... 3 Link to comment Share on other sites More sharing options...
gebeer Posted February 27, 2023 Share Posted February 27, 2023 Time to revive this 8 year old thread ? I'm using vscodium as editor and recently for code formatting I moved from the excellent https://intelephense.com/ extension to an extension that uses https://github.com/PHP-CS-Fixer/PHP-CS-Fixer which is based on https://github.com/squizlabs/PHP_CodeSniffer. This allows custom style definitions (rulesets) https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file PW coding style guide says: Quote The ProcessWire coding style guide is based on PSR-1 and PSR-2 (with many sections copied directly from them), but with several important differences and additions. Has anybody ever gone through the trouble of creating a custom PW ruleset.xml? Just asking before I start spending my time on that. Other CMSs/Frameworks do have their ruleset files. Seehttps://github.com/WordPress/WordPress-Coding-Standards https://www.drupal.org/docs/contributed-modules/code-review-module/installing-coder-sniffer https://github.com/fossbarrow/laravel-phpcs Would be great if we had one for ProcessWire, too. Maybe @ryan already uses one and can share it? If not, we could start a community effort to produce such ruleset. It would help tremendously for PRs to the PW core or for module development. 3 Link to comment Share on other sites More sharing options...
Recommended Posts