Leaderboard
Popular Content
Showing content with the highest reputation on 03/17/2020 in all areas
-
Goldkinder Psychotherapie Website of the child and youth psychotherapist Heike Maßen from Mönchengladbach, Germany. A one-pager that gives an insight into her work and her practice rooms, as well as information about many relevant aspects. It's a simple responsive one-pager with a nice design from Uta Hugenbruch. The front end is build without any framework.6 points
-
@Mike Rockett, how do you feel about preventing caching — entirely, or as a config setting — for logged in users? I think it's probably a bit unexpected that sitemap can include pages that guests have no access to ? In cases where sitemap is cached for logged in users, cache key should probably include the roles of the user. That won't be entirely bulletproof, but at least less likely to cause problems ?3 points
-
Everybody please take this pandemic really seriously!! Panic does not help for sure, but ignorance or underestimating this situation will cost the life of thousands of people all over the world! As the following chart shows, the mortality highly depends on the amount of people that are in need of medical care at one time! Taken from link 2, see below. I have underestimated it myself just like almost anybody in europe has, as nobody of us here has ever experienced a situation like this before (in contrast to asia). Here are two links that I encourage everybody to read, even if you live in an area that has not (yet) been affected: 1) https://www.washingtonpost.com/graphics/2020/world/corona-simulator/?fbclid=IwAR0ABgvQGxm005seLywxDkZScKImi53Du9lzAlMwrDH6qsaaefW-Oux-Gao They have great simulations of how such an exponential growth can/will happen and what every single person can do against it! 2) https://medium.com/@holger.heinze_81247/coronacodex-my-commitment-during-the-covid-19-pandemic-76613656dac0 I hope that was not offending the forum rules that don't want political discussion... I work 100% remote now and I encourage everybody to do the same if at all possible. Not because I'm afraid (luckily I'm not at high risk as I'm young and healthy), but to take responsibility for all the people around me and keep the number of people needing medical care as low as possible so that the staff in the hospitals does not have to decide which patient (with severe symptoms) is treated and which is not (and will likely die).3 points
-
My local shop is well stocked with most things at the moment except milk (there's still a little), pasta, toilet rolls, paracetamol and Maltesers chocolate. Someone out there is preparing for a Netflix binge-watching session sitting on a throne of toilet rolls whilst getting fat on maltesers and presumably taking the paracetamol after they get a chocolate-induced headache I guess ?♂️ I saw someone today buying a large quantity of bottled water as well. I'm fairly sure that still comes out of taps just fine ? It's a pandemic, it's not quite the same as the apocalypse ? But in all seriousness, it is a very strange time. I just hope that those in need of vital supplies can still get them. Stay safe folks and, if you can, stay indoors.2 points
-
This is the topic for the new module, TextInputAwesomeplete. Github: https://github.com/outflux3/TextInputAwesomplete Modules Directory: https://modules.processwire.com/modules/text-input-awesomplete/ Text Input Awesomplete Key Points: Uses Awesomplete JS library for instantiating autocomplete suggestions on text input fields in Processwire CMS. Supports any text field, including Page Title (FieldtypePageTitle). Allows admins to configure a list of suggestions (textarea input), or pull suggestions from Processwire pages, by configuring which pages to pull from and which field's value to use. About Awesomplete https://leaverou.github.io/awesomplete/ https://github.com/LeaVerou/awesomplete Benefits & Uses Can be helpful for fields where users may need to enter the same text in the same field on multiple pages, and you can't or don't want to use a Page Reference field. One example could be a site where you send emails using various boilerplate subjects; Another place to use this would be if you had an existing site with a text field that has some inconsistency when same values are added. The autocomplete would help editors to always use the same format as the other pages with the same value. Installation Upload or install from Modules directory. Usage & Configuration Once installed, on any text input field (including Page Title), you will see an option to enable autocomplete. Once enabled you will have the option to type a list of items for autocomplete suggestions, or enable the module to search pages for suggestions. Note that if you enter any items in the Items List field, those will always be part of the autocomplete suggestions, in addition to pages if configured. If you elect to use pages for the suggestions, you have these options: Choose a template to limit by (adds a template=sometemplate to the pages find selector). Override which field to pull suggestions from (by default it will use the field you are configuring). Sets the $field!= in the selector. Setup a Selector for finding the pages for the autocomplete suggestions. This overrides the template selected. Note that the selector needs to return pages that use the field being configured, or the field selected for override. Screenshots: (1) Examples of in-use: Module Configuration Screen1 point
-
Inspired by a recent question. Image Crop Ratios Allows preset aspect ratios to be defined per image field for the ProcessWire image crop tool. The module adds a select dropdown to the crop tool. Choose an aspect ratio and the crop area will be fixed to that ratio. Screencast Installation Install the Image Crop Ratios module. Configuration Default aspect ratios for all image fields can be defined in the module config. Aspect ratios for specific image fields can be defined on the Input tab of the field settings. You can override the ratio settings in template context if needed. Insert a hyphen as the first item in the ratio settings unless you want to force a ratio to be applied to the crop tool. The hyphen represents a blank option that allows a free crop area to be drawn. Usage Click the "Crop" link on the details view of an image thumbnail. Click the "Crop" icon at the top of the editor window. Choose an option from the "Ratio" select dropdown. https://github.com/Toutouwai/ImageCropRatios https://modules.processwire.com/modules/image-crop-ratios/1 point
-
As I understand it, PHP_EOL means "the end of line character for the current system". So when the code executes on Windows it equates to "\r\n" and when it executes on *nix it equates to "\n". It's cross-platform when it comes to outputting a line-break character, but not when it comes to looking for line-break characters in user input from Windows and *nix. I usually do this... $lines = explode("\n", str_replace("\r", "", $input)); ...which is faster than regex.1 point
-
Hi @kongondo just very curious as a padloper customer. Would it be possible for you to communicate a tiny bit more about what is happening maybe when to expect the fruit of all your hard work just so we know when to budget our sending you money for the upgrade to the next version thanks!1 point
-
@Sevarf2 If you want to test this, you can add the following code to the module at the end of "SettingsFactory.module". /** * @var $key - the settings key * @var $_key - the setting within the key * @var $value - the new value */ public function changeSetting($key,$_key,$value) { $modData = $this->modules->getConfig('SettingsFactory'); if(!array_key_exists($key, $modData)) return; if(!array_key_exists($_key, $modData[$key])) return; $modData[$key][$_key] = $value; $this->modules->saveModuleConfigData('SettingsFactory', $modData); } and then this would be the way to change the setting from api: $factory->changeSetting('wiretabs-testing1','settings_client','new value'); in limited testing this has worked fine, but i'd recommend a few more tests before using on production. I haven't commited this to the master yet - it probably needs to include a check to ensure the target key exists in this case. This also illustrates that it would be possible to add settings (addSetting), but since the fieldset is defined in a hard file, any settings added in the api would not be editable in the admin, so not sure if that would be useful.1 point
-
Hi @ukyo I just created a PR to support easy value setting via setAndSave(). Before: After: $page->setAndSave('contact', ['str' => 'foo']); https://github.com/trk/Mystique/pull/31 point
-
Ah! Ok, we have found the reason - super!!! ? : in the "home" template the family was really the config "one, not more allowed" and in addition i have forget to delete in Files "Attached a file" my new (deleted) template. Great, thanks a lot for your help - i really thought that i had reset all configurations, then i try again with my repeater template ...1 point
-
You don't even need to adjust your template, as long as the rows have one common parent you can use the CSS nth-selector: .row { display: flex; flex-flow: row nowrap; justify-content: space-between; align-items: center; } .row:nth-child(2n) { flex-direction: row-reverse; }1 point
-
If using flexbox you could use the order property to change the order of the columns, I normally add a class to a parent div that wraps both columns. foreach($page->repeater as $i => $item){ //Going to offset the count starting from 1 instead of 0 so I can use modulo operator $i = $i + 1; $class = ""; // If the count is even, such as 2,4,6, etc. if($i%2 == 0){ $class = "invert-order"; } echo "<div class='row {$class}'>"; //output the columns here echo "..."; echo "</div>"; } You should end up with something like this: https://codepen.io/elabx/pen/RwPMaym1 point
-
THX! Nothing to be sorry about! Was just a suggestion for an improvement ? This looks like a fantastic module. I'm testing ?1 point
-
1 point
-
I confirm that this works - when I called trackChange before save the change to the image description field was savedA. Thanks again Horst. As a footnote, when updating tags I found that I can use $image->addTag('foo,bar,baz') without trackChange and tags were saved because it's a dedicated function to add tags. Regards1 point
-
1 point
-
Just a heads up, I hope this might save someone some time in the future. TL:DR> It's taken me hours to work out that Apache version 2.4 <If> statements are broken when trying to do regular expression matches against the %REQUEST_URI variable. Try matching against the variable called %THE_REQUEST instead - but be careful with your regex. Background: I've been trying to add more relaxed CSP headers for the admin portion of one of my PW sites because my default, strict, CSP headers stop some admin features from working properly. After diving in to Apache2 regexs and conditionals, I thought I had the answer with this... <If "%{REQUEST_URI} !~ m#^/admin/?#i"> # CSP headers for external visitors. Header set Content-Security-Policy "<strict policy for public site>" </If> <Else> # CSP headers for admin visitors. Header set Content-Security-Policy "<lax policy for admin>" </Else> ...but I couldn't make it work. After experimenting for several hours I found that the regex shown above does work if you limit it to a single-character match; which is essentially useless for determining if we are in the admin interface. However, you can achieve a useful match with the following... <If "%{THE_REQUEST} !~ m# /admin/?#i"> ... </If> <Else> ... </Else> ...which checks verses the entire HTTP request line made to the server. This block can go in your vhosts file or in the site's .htaccess file. Here's the Apache documentation: https://httpd.apache.org/docs/current/expr.html and it seems I'm not alone in having this issue: https://serverfault.com/questions/940953/apache-if-statement-not-working?noredirect=1&lq=1 although neither of these links had workable solutions for me.1 point
-
Nginx' performance advantages over Apache were built on three factors: modern-day multiprocessing in the server, a lot less overhead due to reduced functionality and memory caching. Over the last five years, Apache has greatly reduced that gap by adapting Nginx' multiprocessing approach (one keyword there is the event MPM module), so Apache isn't spending most of its time spinning up and tearing down whole server instances anymore. File system access has greatly improved with solid state disks, too. Apache still has a lot more functionality, and its distributed config file approach, most prominently the ability to make configuration changes with a .htaccess file inside the web directories, hurts performance. Its dynamic module loading approach and the dozens of pre-installed modules most distributions ship also take up processing time and memory. Nowadays, Apache can be stripped down a lot and compiled to be head to head with Nginx, though few actually care to do that, since it also means removing functionality one might need in the future. A stock Apache is usually still quite a bit slower and reaches its limits faster (about the factor 2). This becomes an issue under heavy load or on slow machines. Where Nginx still shines brightly is load balancing. Apache can do it too, but with Nginx it is straight forward and well documented, having been there for a long time. For those interested in a bit of (highly subjective) history: for a long time (speak eighties and nineties), the classic forking mechanism that was common on *nix OSes was the way to do multiprocessing in network servers, and therefore in Apache too. This meant spawning a full copy of the server process and initializing it, then tearing it down when the request was done. Apache brought a small revolution to that approach by implementing preforking, meaning to keep spare server instances around to fulfill requests with little delay. After a while, there were other approaches too when faster multiprocessing approaches become part of common operating systems, like multi threading, which is supported by Apache's "worker" multiprocessing module (MPM). There were, however, big caveats with using other MPMs. Since file systems used to be slow, sometimes awfully so, in the old days, and since the classic CGI approach of starting an executable from the file system, supplying it with information through environment variables and standard input and capturing its standard output was a security nightmare - even without thinking about shared hosting - nifty programmers included full languages interpreters inside Apache modules. mod_perl and mod_php became the big thing, the latter coming to dominate the web after a few years. These interpreters, though, often had memory leaks and issues with thread isolation, meaning at best that an error in one thread tore down numerous other sessions and at worst that the server had a propensity for information leaks, remote code execution and privilege escalation attacks, the former security nightmare squared. Thus, these tightly integrated interpreters more or less locked their users into the classic prefork approach where every instance is its own, basically independent process. With PHP as the market leader not evolving in that regard, things were frozen for quite some time. This was when Nginx conquered the market, first by serving static HTML and associated resources with lightning speed (CMSes generating static HTML were still a big thing for a while), but soon by taking care of all the static stuff while handling the dynamic things off to Apache and caching parts of its responses in memory. Finally, though, PHP finally got a fresh boost and grew stable enough for its engine to re-use interpreter instances. It was easier to contain things inside an interpreter-only process instead of dealing with all the server peculiarities, so FastCGI daemons finally became stable, known and used, and suddenly the need to have the language interpreter contained in the web server fell away. Apache got leaner and Nginx more flexible. Caching servers like Varnish became popular since it suddenly was relatively easy to build a fast, nice, layered caching solution with a combination of Nginx, Varnish and a full fledged web server like Apache or IIS, able to serve thousands of highly dynamic and media rich pages per minute. About that time, SSL grew in importance too, and hosting providers learned to love Nginx as a means to route domains to changing backends and provide fast and easily configurable SSL endpoint termination. Over the last years, Nginx got other features like generic TCP protocol load balancing that offset it from other servers and make it more into a one-stop solution for modern web applications. It does boost its popularity that Nginx is often the first (or the first major) web server to ship evolving technologies, making the front pages and pulling in early adopters, http/2 being one of the most prominent examples there.1 point
-
First, some background to lit a light. There are some functions in PHP that may produce unexpected results in special situations. This functions are used by PW core files and in user contributed modules. Some users may have problems with file upload (pdf, zip, image, whatever) if filename has non-ascii character at the first place. For example, if user upload a file named "år.jpg" (year in Swedish language), it is expected that PW would transliterate (transform) the filename to "ar.jpg", but because of the bug in basename() PHP function, the filename would become just "r.jpg". Nevertheless the file would upload successfully. But if the filename is "привет.jpg" (Hi in Russian language) the upload would fail. There are two ways how to handle this: Write and use custom functions instead of builtin functions Let end user fix that with proper locale Option 1. is used in some CMS/CMF (like Drupal), PW (Ryan) opted for option 2. After successful login PW perform a test and warning is issued in case of test failure. It is now your responsibility to set proper system locale. The locale is a model and definition of a native-language environment. A locale defines its code sets, date and time formatting conventions, string conversions, monetary conventions, decimal formatting conventions, and collation (sort) order. Those "problematic" builtin PHP functions are locale aware, that means they work as expected, if locale is configured appropriately. Locale can be set by the underlying operating system or in PHP. Because on shared hosting you don't usually have root access to the OS, the only option to set the locale is by using the builtin setlocale() PHP function. But, before you can use/set the locale, it must first be installed on the OS. On most unix systems at least some basic locales are already there, they are just not used. To check what locale are you currently using and what locales are available for you to use, create the file testlocale.php at the root of your website with the following content: <?php echo "<pre>Current locale:\n" var_dump(setlocale(LC_ALL, '0')); echo "\n\nAvailable locales:\n"; echo exec('locale -a'); Then point your browser to http://yourwebsite/testlocale.php If your current locale is "C" (and you are on unix), then you will probably get warning after login to the PW admin. What you want to do is change the locale to something that has "UTF-8" or "utf8" in the name of the available locales. In your case you would be looking for something like "sv_SE.UTF-8" or "sv_SE.utf8". Now, there is a chance that Swedish locale is not installed. You can ask your hosting provider to install it for you or use some other UTF-8 locale. On most unix systems I have seen, at least "en_US.UTF-8" or "en_US.utf8" is installed. If even that English locale is not available, then look for "C.UTF-8" or "C.utf8". And this is what you have to use as parameter in the setlocale() call: setlocale(LC_ALL, "sv_SE.utf8"); You could actually "stack up" multiple locales and one will eventually work: setlocale(LC_ALL, "sv_SE.utf8", "sv_SE.UTF-8", "en_US.UTF-8", "en_US.utf8", "C.UTF-8", "C.utf8"); Now, regarding where to put that setlocale() call. If you are not using PW multi language capabilities (you don't have Languge Support module installed), then you place setlocale to /site/config.php. That's it. If Language Support module is installed (PW checks for that), you have two options: Translate the string "C" in LanguageSupport.module for each installed language Put setlocale() call in /site/init.php My preferred method is option 1 and this is what PW (Ryan) recommends. See https://processwire.com/api/multi-language-support/code-i18n/ for more info on translating files. Option 1 allows you to set different locale for each of the installed language, while option 2 allows setting of one locale for all languages. PW will also provide links for the files that needs to be translated in the warning message. Ryan just pushed an update that makes it use the locale setting on the frontend when using LanguageSupportPageNames module (until now just language was changed, but not locale). Also setLocale() and getLocale() methods are added to the $languages API var.1 point
-
I think you're misunderstanding registering/executing hooks. When you register a hook, you do not call anything. Basically you tell ProcessWire that you want to execute custom logic whenever the hooked method is executed. In your case, your method "addInlineScript" is called after Pw rendered your page (after executing $page->render()). Autoloading just makes sure that your hooks are properly setup, before hooked methods are executed. You don't need autoloading, but then you must be sure that "registering" the hook happens before Pw executes the hooked method. Sorry if the above does not make any sense, it's not easy to explain this stuff as non-native english speaker/writer1 point