Leaderboard
Popular Content
Showing content with the highest reputation on 02/18/2022 in all areas
-
Info here: https://github.com/processwire/processwire-requests/issues/173 You probably want FieldtypeDecimal (was a third-party module, now part of the core) for accurate decimal numbers.4 points
-
+1 for installing Decimal by default and perhaps even making Float uninstalled by default.3 points
-
Thanks Horst! The thing is, Tracy Debugger does deal with all "errors" for us, so it might be a better idea to ask @adrian to take special care of deprecated (and maybe warning) messages so that they do not show up in Tracy's debug bar as "errors", highlighted with red labels. Maybe Tracy could maintain two "bags", I mean sets of php error messages for us, one for low level of importance and one for high level of importance, and each set could show up in the debug bar under its own "label". High level of importance errors should be red as currently, while the low level of importance "errors" could be under a green label. On the Tracy settings page we could configure what goes where, and a sensible default would be set for us, of course. So whenever I see some "green error" messages in Tracy and its log, I know that currently there is nothing urgent to check out, but if I want to, all the messages are there for me to examine.3 points
-
I'm honestly not sure how I feel about this, but that's another story :) The feature that you're asking for probably belongs in the Tracy core, so it might be best to request it over here: https://github.com/nette/tracy/issues That said, I have hacked together something (fairly quickly, but definitely not 5 minutes). Try the attached - currently only works for direct loading of frontend pages - ie it doesn't work in the admin or via AJAX. The errors panel gets recolored if the only errors in it are deprecations. Sorry, I don't have anymore time to spend on this at the moment, especially given that I think it belongs in the Tracy core. TracyDebugger.module.php2 points
-
@wbmnfktr Thanks! Mapping different work trees to different virtual hosts is a great idea, probably what I was missing for this to make sense to me. I'll try this out when I get the chance. @dotnetic The different dependencies can just be tracked in the package.json / composer.json files (and the respective lock files) and installed with npm ci or composer install. Both tools cache packages locally, so it usually only takes a couple of seconds ... I guess this would be useful if you need to switch branches every couple of minutes, though I can't think of a workflow that would require that much switching ?2 points
-
That doesn't look like the correct syntax for setting multiple sorts in a selector string. I think it should be "sort=template, sort=-created" https://processwire.com/docs/selectors/#sort To apply it to the admin search using a hook: $wire->addHookAfter('ProcessPageSearch::findReady', function(HookEvent $event) { $event->return .= ', sort=template, sort=-created'; });2 points
-
I also prefer to use foreach + endforeach or if + else + endif when working in markup. It's a lot cleaner to read than single brackets being somewhere in the file within <?php and ?> You can get rid of the if/else though because you are outputting the wrapping div of $date anyhow. This is how I would format your code: <?php $items = $pages->find("homepage_item=1"); $date = $item->arbitrary_publish_date; ?> <div class="row mb-2"> <?php foreach($items as $item): ?> <div class='col-md-6'> <div class='row g-0 border rounded overflow-hidden flex-md-row mb-4 shadow-sm h-md-250 position-relative'> <div class='col p-4 d-flex flex-column position-static'>"; <h3 class='mb-0'><?= $item->title ?></h3> <div class='mb-1 text-muted'><?= $date ?></div> <p class='card-text mb-auto'><?= $item->summary; ?></p> <a href='<?= $item->url ?>' class='stretched-link'>Continue reading</a> </div> <div class='col-auto d-none d-lg-block'> <svg class='bd-placeholder-img' width='200' height='250' xmlns='http://www.w3.org/2000/svg' role='img' aria-label='Placeholder: Thumbnail' preserveAspectRatio='xMidYMid slice' focusable='false'> <title>Placeholder</title> <rect width='100%' height='100%' fill='#55595c' /> <text x='50%' y='50%' fill='#eceeef' dy='.3em'>Check it out!</text> </svg> </div> </div> </div> <?php endforeach; ?> </div> @taotoo you have some missing echo statements in your code Note that I'm also wrapping code after 80chars usually, see https://stackoverflow.com/questions/578059/studies-on-optimal-code-width2 points
-
This module enables Selectize (which is bundled with the PW core) on all Select and AsmSelect inputfields in the PW admin. As described below in the readme, Selectize is initialised/destroyed as the revelant select is focused/blurred in order to support select options that change after the page is loaded. Therefore Selectize is styled to match the AdminThemeUikit select as closely as possible to minimise the visual change as the select is focused and blurred. I'm developing on Windows so I'm not sure how the module will render on other operating systems. It doesn't help that the PW admin uses different fonts depending on the OS - I wish PW would bundle its own webfont for a standardised appearance everywhere. Incidentally, I was a bit disappointed with the state of the Selectize project. I had to fix or work around a number of bugs and shortcomings, including things you would think would just work out of the box such as disabled options, matching the width of the replaced select, or the standard select behaviour where a selection is required when there is no empty option. The Selectize issues repo is full of arbitrarily closed bug reports and pull requests and there are no updates for the last 6 years. I've tried to catch everything that would affect this module but I wouldn't be surprised if there are still some bugs. Selectize All Enables Selectize on all InputfieldSelect and InputfieldAsmSelect fields in the ProcessWire admin. The module activates Selectize on the <select> element when it is focused, and destroys Selectize when the element is blurred. This allows Selectize to work on selects where the options are changed dynamically after page load depending on other field values, e.g. the "Select File" field in the CKEditor link modal or a dependent select in Page Edit. Only AdminThemeUikit is tested and supported. Usage In the module config you can choose if Selectize should be used with InputfieldSelect, InputfieldAsmSelect, or both. If you want to disable the module for a specific Select or AsmSelect inputfield you can hook SelectizeAll::allowSelectize. This method receives the Inputfield object as the first argument. Example: $wire->addHookAfter('SelectizeAll::allowSelectize', function(HookEvent $event) { $inputfield = $event->arguments(0); // You can also get any associated Page and Field objects via $inputfield->hasPage and $inputfield->hasField // Disable the module for the inputfield named "template" if($inputfield->name === 'template') $event->return = false; }); https://github.com/Toutouwai/SelectizeAll https://processwire.com/modules/selectize-all/1 point
-
Natasha Marques is a desserts chef and chocolatier from Brazil with an international carreer. Now established in my hometown Porto, she's about to open a shop and already shipping her premium line of sweets and desserts. The website is my usual combo of PW with StencilJS frontend with a content blocks approach. Minimal stack of modules: SeoMaestro, WireMailSmtp, and my own block selector module which is a hacked version of FieldSelectFile. The site is only in portuguese, but have a look anyway: https://arbynatashamarques.com/1 point
-
If you want, you can filter them out and focus more on your essentials. But first things first. There is a whole list of different PHP errors, warnings and hints (notices). The one we are interested in is E_DEPRECATED. These messages indicate that a used PHP function somewhere in the code is no longer supported in a future, i.e. higher PHP version, not the actual used one. Example: The days (February 2022) I have changed my developer machine to use the latest PHP version 8.1.2. The last PHP 7.4+ is still supported for 9 months from today on, PHP 8.0 still for 1 year + 9months, PHP 8.1 for 2 years+ 9 months, and all other PHP 8+ versions each plus one more year. So the point is clear now, right? It will be year(s) before PHP 9 is on the schedule. ? Currently in v8.1.2, depending on what code I run, I get notices that certain PHP functions will no longer be available starting with PHP 9. (PHP 9! see above). So currently these functions are safe and supported functions, as in past versions as well as in all further PHP 8+ versions(!). No matter how many additional PHP 8+ versions there will be. ProcessWire by default allows us to suppress ALL output, or show ALL output, by the boolean configuration variable "$config->debug". This is good and right, because on a production site you should always suppress all those outputs. On a developer machine it usually shouldn't bother you if there are also E_DEPRECATED hints included. But if it does, you can filter them out as follows, for example. In your site/config.php you can define a own error handler function and load / bind it on your developer machine only. As a proof of concept or simple example, I added the following function to my site/config.php /** OWN ERROR HANDLER FOR DEPRECATION NOTES **********************************************/ function myLocalDevDeprecationErrorHandler($errno, $errstr, $errfile, $errline) { if(!isset($GLOBALS['DEPRECATION_WARNINGS_BAG'])) { $GLOBALS['DEPRECATION_WARNINGS_BAG'] = []; } if(!is_array($GLOBALS['DEPRECATION_WARNINGS_BAG'])) { $GLOBALS['DEPRECATION_WARNINGS_BAG'] = []; } $GLOBALS['DEPRECATION_WARNINGS_BAG'][] = [$errfile, $errline, $errstr]; return true; // true | false = suppress further processing } /** OWN ERROR HANDLER FOR DEPRECATION NOTES **********************************************/ With the following call, also located in my developer machines site/config.php file, I bind it to all raising E_DEPRECATED warnings ONLY! So we are sure and free from all other types of errors, warnings, hints, etc. // preceed the callback function name with the PW namespace, // and define the error types that should passed to the function set_error_handler('ProcessWire\myLocalDevDeprecationErrorHandler', E_DEPRECATED); (read more on php.net) Now you will not see any of the deprecated notices any more, cluttering your screen. Neither in the front end nor in the backend. But they are all collected in our bag. ? A simple loop in the site/templates/admin.php, before the controller.php is called, can display any of it, maybe to the superusers only, for example: <?php namespace ProcessWire; // IF WE HAVE CACHED PHP DEPRECATION WARNINGS, SHOW THEM IN THE ADMIN, FOR SUPERUSERS ONLY if(isset($GLOBALS['DEPRECATION_WARNINGS_BAG']) && is_array($GLOBALS['DEPRECATION_WARNINGS_BAG']) && 0 < count($GLOBALS['DEPRECATION_WARNINGS_BAG']) && $user->isSuperuser()) { foreach($GLOBALS['DEPRECATION_WARNINGS_BAG'] as $deprecatedMessageItem) { $deprecatedMessageItemMSG = "PHP DEPRECATED (v". PHP_VERSION .") = \n "; $deprecatedMessageItemMSG .= "{$deprecatedMessageItem[0]} : [{$deprecatedMessageItem[1]}]\n "; $deprecatedMessageItemMSG .= "{$deprecatedMessageItem[2]}"; $this->message($deprecatedMessageItemMSG); } } require($config->paths->adminTemplates . 'controller.php'); If you want to show them on the front end to, it belongs to how you have organized your output strategy. I use a delayed output with _init.php and _main.php, where I have a special function for adding all kind of debug messages, that gets displayed on the end of the site, after the footer. Simply adding the whole collected array is enough for my information: if(isset($GLOBALS['DEPRECATION_WARNINGS_BAG']) && is_array($GLOBALS['DEPRECATION_WARNINGS_BAG']) && 0 < count($GLOBALS['DEPRECATION_WARNINGS_BAG'])) { mvdr(['DEPRECATED ('. PHP_VERSION .')' => $GLOBALS['DEPRECATION_WARNINGS_BAG']]); // add it to the debug output region var } The outputs in admin then may look like this Or the very basic info for me on front end1 point
-
Kind of heckling here, yet... I didn't even know anything about this in that depth... therefore... just a THANK YOU for this insight.1 point
-
If you end up making this feature request I'll surely give it a thumbs up. I am so used to this "errors" count in the Tracy bar I do not even look at them anymore. How are you doing, @horst! I reeeealy like that color indication and LOCAL label. Could you share how you achieve that? I would use it on every site of mine.1 point
-
Heard of it, but not tried it. For now I think I'd rather keep issues and requests in one place, and discussions here at the forum. Definitely something to keep in mind though ?1 point
-
Hey @szabesz, Sorry for the delayed answer, busy week here ? Public RSS feed is rendered by ProcessChangelogRSS module, which hooks into ProcessPageView::pageNotFound. If you can, you could... a) check if the module gets called properly (by adding some debug code to init() method), b) check if the hook gets triggered — in which case we could rule out any config setting or key related issues —, and c) if not, make sure that code in templates or some other module is not preventing the hook from working (URL segments being enabled on the home template is potential culprit, because 404 needs to be triggered in specific way or hooks no longer work as expected). Of course it could be an issue with the module as well, but it did work last time I used it... which was a while ago ? If I recall correctly, I added this as a sort of "power user feature", so that while it can be used, it's intentionally somewhat obscure. This is in part because the data structure for Process Changelog is really quite awful for that sort of query. Anyway, I'll look into this (https://github.com/teppokoivula/ProcessChangelog/issues/33) ? Makes sense to me. I'll look into this as well (https://github.com/teppokoivula/ProcessChangelog/issues/34). That's a quick one: I've never used this combination. In fact I don't think I've ever used ProDrafts, apart from some quick tests way, way back. If changes made while ProDrafts are made to pages, they'll get logged. If it has a custom data storage or if it prevents hooks from running, then they won't be logged. I don't have a test setup for this at hand, so can't confrim this easily. There's a hookable method — ProcessChangelogHooks::shouldLogPageEvent($page, $field, $operation) — which you could likely use to prevent Process Changelog from logging such events, at least assuming that there's something about the Page or Field (alone, or in combination with session data, etc.) that makes such edits identificable. In other words I'm pretty sure that this is doable, but it may well require custom hook. Let me know if you try this, and perhaps I can help with getting that setup up and running. Though, again, I've zero experience with ProDrafts, so... ?1 point
-
@horst I did not mean your "request" belongs to that category but I was probaly not that clear about that, sorry....1 point
-
Outch! ? EDIT: but, but, - uhm, - but I enclosed a "(hopefully)" already, ...1 point
-
Well, since there is no "just a five minute task" – even though our clients often firmly believe in such a thing –, I have not yet wanted to turn this idea into a feature request but I would be happy to hear Adrien's reply. The last time I checked what PHP error level constants exist there were fewer than currently, so as the language evolves, these constants evolve too. Which means there are differences between PHP versions in this regards as well, so dealing with error level constant differences might mean some extra effort on Adrian's part, I guess.1 point
-
That sounds good. And I think it should not be much work (hopefully) for @adrian to incorporate that. It needs just a separation of different PHP error and warning types through dedicated error_handler function(s). I think everything that belongs to the group of "best practices and deprecations" could go into the green bag, where as all other stays in the red one. ?1 point
-
Thanks I will look into this and if it works I will update this post ? Update: Approach works ? $this->addHookAfter('ProCache::allowCacheForPage', function (HookEvent $event) { $event->return = (!empty(\DROPLET_HOSTNAME) && (\DROPLET_HOSTNAME === "my-droplet-production-01" || \DROPLET_HOSTNAME === "my-droplet-stage-01")) ? true : false; });1 point
-
1 point
-
1 point
-
I'd use Nette then: https://doc.nette.org/en/utils/images1 point
-
@MoritzLost I didn't use worktrees yet, but one advantage that I have seen in videos is, that you have your own dependencies for each worktree. This can be a huge advantage if you use different node modules (or composer dependencies) between branches (maybe because you need an additional library for a feature branch)1 point
-
I'm not using them day-to-day... that would be such an overhead. But yes, worktrees are some kind of next-level chaos at first. Still sometimes really nice. I used worktrees in some larger projects in which lots of things happened at the same time. So switching from branch to branch, stashing, half-baked commits didn't work out at all. I mapped each worktree to its own virtual host, could switch code bases whenever needed without said things, like stash or commit. Are they perfect? No. At least not in my day-to-day projects. But there have been some projects I really benefitted from worktrees. Still a tiny fraction, but still. I assume it will work out totally different in case you do C/C++, Rust, Go, TS... things like that. At least that's my impression while watching coding session similar to video linked above.1 point
-
With all respect to the beautiful website .... but the domain name ? I have seen a lot of domain names but never something like this. Think of Visitors outside of Brazil and who is going to memorize something like arbynatashamarques ? Even on a business card it would look kind of absurd. A domain name should be short, easy to memorize and recognizable for a brand, a service, a product, etc. etc. But maybe this is just me.1 point
-
Hello Seba, yes, this is possible. I have connected the login to our domain controller via LDAP and the control of the authorisations runs via corresponding groups. (Customized Version of this Module: https://github.com/conclurer/LdapSignIn ) in general, its just a normal website with access protection ?1 point