Leaderboard
Popular Content
Showing content with the highest reputation on 11/17/2021 in all areas
-
hi, my name is carson, and I created htmx and, since we're here, hyperscript.org (for lunatics only)13 points
-
? I appreciate that, but htmx is fairly feature complete and is supported by my other work. intercooler.js, the predecessor to htmx, has been up for nearly a decade without any sponsorships: https://intercoolerjs.org I don't anticipate htmx being any different, although I always do appreciate any sponsorships! Thank you for the warm welcomes. I don't know how useful I'll be, but I'll try to answer any questions I can around htmx as honestly as possible.7 points
-
6 points
-
Generally that's correct, htmx.onLoad() replaces the standard jQuery initalizer. Only real trick is that you initialize stuff in the content passed in to the onLoad() callback, rather than initializing the whole document like you do normally in jquery: Note that the query selector is run against the newly inserted `content` element, rather than globally, so you can initialize the library just for the new content that has been added to the DOM (and avoid accidental double-initialization of things.) Alternatives are: using alpine to init the element on load using hyperscript to init the element on load The first one is sane, but not how I would do it unless I already had alpine in my code base and I was comfortable with it. The second one is insane and not recommended, but I do love hyperscript.4 points
-
After enabling WebP support you may notice it can take a long time for ProcessWire to create WebP copies of all images and their variations. For instance, on a site I work on (with over 10k images), it was taking about 1 second per image, ie. more than 3 hours in total.. ? If you are comfortable around the command-line, you can use the cwebp program and this bash script to speed things up drastically. I have built upon this script and got things to work in combination with xargs and find, making it rather powerful for PW's purposes. 1. Save this script as 'convert-webp.sh' (or download the Gist from Github), and follow instructions ######################################################################################################### # # Fast Recursive Images to WebP converter # Customized for ProcessWire CMS/CMF <https://www.processwire.com> # # Author: Eelke Feenstra <dev@eelke.net> # Version: 001 # Based upon: https://github.com/onadrog/bash-webp-converter # # Quick & dirty script to add webp versions to all PNG / JPG / JPEG files inside your PW assets folder # # 1. Set this script to executable: # $ chmod +x convert-webp.sh # # 2. Check if cwebp is installed: # $ cwebp -version # If it is not, install: # $ brew install webp # Or follow instructions https://developers.google.com/speed/webp/download # and change $executable to cwebp's full path # # 3. Run the script directly on a folder: # $ ./convert-webp.sh /path/to/your/folder # ######################################################################################################### # Configuration executable="cwebp" # update this to reflect your installation! quality=90 # change to desired WebP quality ######################################################################################################### converted=0 skipped=0 echo "Entering $1" for file in $1/* do name="${file%.*}" echo "FILE: $file" echo "NAME: $name" # Skip the folder itself.. if [ "$name" = "./." ]; then echo "SKIP: $name" continue; fi if [[ $(file --mime-type -b $name.webp) == image/webp ]]; then echo "FOUND: $name.webp, skipping.." skipped=$((skipped+1)) elif [[ $(file --mime-type -b $file) == image/*g ]]; then echo "NOT FOUND: $name.webp" newfile(){ echo "$file" | sed -r 's/(\.[a-z0-9]*$)/.webp/' } $executable -q $quality "$file" -short -o "$(newfile)" converted=$((converted+1)) fi done echo "Converted $converted, Skipped $skipped" 2. Run to create webp versions of all jpg/jpeg/png images in a given folder (for example the site's homepage) $ ./convert-webp.sh /path/to/processwire/site/assets/files/1 3. And in order to create WebP copies of ALL images inside the /site/assets/files folder, you can run this script. It searches for all directories inside the files directory, and passes these to the convert-webp.sh script using xargs. $ find /path/to/processwire/site/assets/files -maxdepth 2 -type d | xargs -I '{}' ./convert-webp.sh '{}' Tested both on MacOS 12 and Debian4 points
-
hey @adrian hope you are fine ? today I noticed a very strange issue with this little and simple module: When I do this: $m = $modules->get('Demo'); db($m); db($m->url); ...in the Tracy Console it does NOT show any data when I'm in the module's config screen. When I'm on any other page it shows data as it should. Note that the issue does only occur on a non-autoload module. Making the module autoload fixes the issue (that might help for debugging). Any ideas why this could happen? --- On module's config page: On any other page:2 points
-
Another cool way to do this would be to let ProcessWire take care of the main selector string, because you don’t really want to write page status checks and all that stuff yourself. $query = $pages->getPageFinder()->find('template!=admin, has_parent!=2, include=all', [ 'returnQuery' => true ]); $statement = $query->leftjoin('field_title on field_title.pages_id = pages.id') ->where('char_length(field_title.data) > 10') ->prepare(); $database->execute($statement); $ids = $statement->fetchAll(\PDO::FETCH_COLUMN); $results = $pages->getByIDs($ids); For this purpose you could also do the join and the condition in one call using join().2 points
-
Several ways to do it: $page_to_clone = pages(1051); $destination_parent = pages(1016); $new_title = 'Example'; $pages->clone($page_to_clone, $destination_parent, false, [ 'set' => [ 'title' => $new_title, 'name' => '' ] ]); //////////////// wire()->addHookAfter('Pages::cloneReady', function ($event) { $pages = $event->object; $pagesNames = $pages->names(); $oldPage = $event->arguments(0); $newPage = $event->arguments(1); $sanitizer = $this->wire()->sanitizer; $newName = $sanitizer->pageNameTranslate($newPage->get('title')); $newPage->name = $pagesNames->uniquePageName($newName, $newPage->parent); }); //////////////// $page_to_clone = pages(1051); $destination_parent = pages(1016); $new_title = 'Example'; $pages->clone($page_to_clone, $destination_parent, false, [ 'set' => [ 'title' => $new_title, 'name' => $pages->names()->uniquePageName($sanitizer->pageNameTranslate($new_title), $destination_parent) ] ]);2 points
-
Update: The solution is to upgrade (paid) to MAMP PRO 6, this version comes with WebP support. The upgrade costs a lot less than all the time I've spent chasing this bug.. ? Edit: it took really long to convert all images, and I figured out a faster way using the command line. Read more in the tutorial.2 points
-
If I'm understanding the problem right, maybe the PagesNames class could be useful in this scenario?? https://processwire.com/api/ref/pages-names/unique-page-name/2 points
-
The newest posted versions of PageAutosave (v3 and v4 in ProDevTools, ProDrafts, ProFields) adds the following: Support for alternate event driven ajax live preview mode, which appears to provide improved performance and work in live environments where the streaming/SSE didn't. Since this seems to work better, it is the new default setting. The SSE option is still there but you have to manually select it in the module settings if you want it. Support for remembering live preview window position, plus automatically detecting and using an optimal preview window position. Meaning, it'll find the location on the screen where there is the most room for the preview window and then move and resize it there. Once the window is in position (or if you move or resize it) it'll remember your setting in a cookie so that you won't have to move and resize your live preview window every time you edit another page. Automatic insertion of pw-value-* classes in markup to support replacement of individual fields native to $page, without having to re-render the page. This means you no longer have to insert your own pw-value-* classes in markup for improved performance, as the module will do it for you when rendering a live preview request. If it causes any issues with your site, you can optionally turn off the feature in the module settings.2 points
-
htmx supports using morphdom for swapping with the morphdom-swap extension agree 100% w/ @Craig's characterization of htmx as lower level than unpoly: it's an extension of HTML rather than a full framework (with, for example, a notion of layers). That can be good or bad, depending on your needs. Unpoly is a wonderful library that follows the same general html-oriented approach, but provides a lot more infrastructure baked into the core. I think either one (or, hotwire, for that matter, which is even higher level than unpoly) is a great choice for html-oriented development. I obviously prefer the lower-level "improve on HTML" approach, but they all have plusses and minuses. I'm (all to) happy to chat about htmx either here, on the htmx discord, or anywhere else. -t.totallyNotAnHtmxShill2 points
-
An Images field allows you to: Rename images by clicking the filename in the edit panel or in list view. Replace images, keeping metadata and filename (when possible) by dropping a new image on the thumbnail in the edit panel. Introduced here. But neither of these things is possible in File fields, which prompted this module. The way that files are renamed or replaced in this module is not as slick as in the Images field but it gets the job done. The most time-consuming part was dealing with the UI differences of the core admin themes. @tpr, gives me even more respect for the work that must go into AdminOnSteroids. Most of the code to support the rename/replace features is already present in InputfieldFile - there is just no UI for it currently. So hopefully that means these features will be offered in the core soon and this module can become obsolete. Files Rename Replace Allows files to be renamed or replaced in Page Edit. Usage Install the Files Rename Replace module. If you want to limit the module to certain roles only, select the roles in the module config. If no roles are selected then any role may rename/replace files. In Page Edit, click "Rename/Replace" for a file... Rename Use the text input to edit the existing name (excluding file extension). Replace Use the "Replace with" select to choose a replacement file from the same field. On page save the file will be replaced with the file you selected. Metadata (description, tags) will be retained, and the filename also if the file extensions are the same. Tip: newly uploaded files will appear in the "Replace with" select after the page has been saved. https://github.com/Toutouwai/FilesRenameReplace http://modules.processwire.com/modules/files-rename-replace/1 point
-
Hello, my Processwire family. Just minutes ago I flipped on the switch for my agency's new website. Check it out here: https://supertiny.agency/ This is a year of changes. I've finished my collab with a major studio, focused back on Supertiny, Liliana joined me for marketing, campaigns and strategy services, and over the last few months I've been working on the agency's website overhaul. Curiosities: Threejs based intro: After learning a few new tricks from the Awwwards winner Bruno Simon and his incredible course, I went oldschool and made an intro for this website. The intro runs once, the session remembers it's been played and turns to a discreet mode if users return to the homepage, allowing a replay. Using my Tiny Cookie Consent as a web component, I made an approach that I'll probably use a lot going forward. I have a text field in the CMS for all the scripts, and with some PHP find/replace that's undone on the client side, trackers and stats are being turned on only when the user allows it. As usual, repeaters and content blocks allow mix and match when building content. The design and overall vibe takes cues from 80's sci-fi. When I started designing this I was playing Control on my PS4 and overloaded with nostalgia, and attempted to convey some of that in this website. Now, there's a bit of an experiment here. All UX bibles are saying that it's a sin make an intro, lock scroll and whatnot. But this is a site users are probably only going to see once. So my approach here is more like a Yield sign. There's an intro, the scroll is locked, but you have a skip button. I'm basically trying to make the user slow down a bit and take in the concept, but let them through if they're really in a rush. Also, as a communication strategy, I'm placing my bets on case studies that will be promoted in social networks, and also new content on the Insights which will hopefully become more interesting with video content. Users coming from there will only see the intro if after seeing that content they get curious and have a lookaround. This is making sense in my head, but it's a bet. I'm curious to see how it performs and if I have to change the approach. Let me know what you think.1 point
-
Thanks for the feedback, Rick! In this case, I'm planning on allowing tags on every page that contains content. Although education-related, we're a public library, so we don't actually teach per-se, but the actual content has no limit. I hadn't yet attempted implementation yet so I wasn't aware ProcessWire doesn't allow multi-word tags, but that could potentially be solved with hyphenation. I'm mostly wondering what people have come up with in terms of rules or procedures on best-case scenarios for instructing users on how to take advantage of tags. I do realize, however, that this may be dependent upon implementation, though I'm curious of first-hand scenarios of others, to maybe apply to my own. (You kind of touched on an idea with the course category subset.) ? Thank you!1 point
-
As far as I know, Processwire has single-word tags only -- Unless someone else can jump in to explain how you can achieve multi-word tags. You do not need to restrict your tags to 'unique' items. Multiple items may have the same tag. As far as defining tags, that depends on your content. Education tag examples could be a subset of the course sub-category, eg, Category=Science, Subcategory="Astronomy", Tags="Telescopes","Planetary Nebula" (Notice the multiple word tag), and other astronomy related stuff. You can also define tags on the fly, rather than creating an initial listing. Hope this helps1 point
-
What if… Visual Studio Code became the editor of in-browser Developer Tools? www.youtube.com/watch?v=77qEmDlFtzg https://www.youtube.com/watch?v=g_TpkkmYzXs1 point
-
There you go ?. Thanks for responding to my Reddit post. It **really** is an honor.1 point
-
Hi Kongondo, We're interested utilising Processwire for e-commerce and therefore your development of "Padloper II". We have enlisted ourselves on your Google form for beta testing. Kind regards, Nigel1 point
-
Thank you for the update. I am always using the latest MAMP PRO and didn't notice this issue anymore. But I also defined as workaround a own config variable "useWebP", which I set to false for my development environment. ? <picture> <?php if ($config->useWebP): ?> <source srcset="path/to/image-webp" type="image/webp"> <?php endif; ?> <img src="path/to/image"> </picture>1 point
-
You can get a bunch of problems by not having the correct URL in $config->httpHosts. Basically anything that generates an absolute URL will fall back to the first one on that list.1 point
-
Looks good and works fine here on all instances.1 point
-
Yes, it works with this three lines in the home template file, but you must enable the urlSegments in the home template.. now the AppApi configuration still have the "domain.com/api/users" as endpoint but "domain.com/users/" works too.. if you try "domain.com/foo/" the api respond with a 404 json response1 point
-
Hi, yes, it could be ? i've had the same problem once forgetting to change this param when migrating my website from local to online have a nice day1 point
-
Hi, as Robin said, so far it's not a native pw selector and, being a great fan of sql queries i do like his solution ? now if you want to take advantage of what pw gives you with selectors, you can just add a numeric field to the templates you want to find name it as you want (i'll use titlelength for my example) in the field tab of the... field set it as hidden then in your ready.php file put something like this (the namespace is just here in case you don't have a ready.php file for the moment) <?php namespace ProcessWire; if(!defined("PROCESSWIRE")) die(); $pages->addHookAfter('saveReady', function($e) { $p = $e->arguments(0); if($p->template != 'template_to_play_with') return; // you could also use an array of templates to exclude and if (in_array($p->template, $your_array)) $ln = strlen($p->title); $p->set('titlelength', $ln); }); now you can filter using titlelength>10 hope it helps have a nice day1 point
-
Welcome to the PW forums ? PW doesn't currently provide a way to find pages by the length of a field value. Although I think it would be a nice feature so I took the liberty of opening a request: https://github.com/processwire/processwire-requests/issues/424 Technically you could achieve it with a custom SQL query: $sql = 'SELECT pages.id FROM pages LEFT JOIN field_title ON field_title.pages_id = pages.id WHERE CHAR_LENGTH(field_title.data) > 10 AND pages.templates_id != 2 AND pages.parent_id != 2 AND pages.parent_id NOT IN (SELECT pages_id FROM pages_parents WHERE parents_id = 2 OR pages_id = 2)'; $ids = $database->query($sql)->fetchAll(\PDO::FETCH_COLUMN); $results = $pages->getByIDs($ids); But you might find it simpler to stick with what you're already doing.1 point
-
This is what I do, which is almost like (2). site/config.php: <?php namespace ProcessWire; if(!defined("PROCESSWIRE")) die(); // Other PW default config values... // ... $config->dbHost = 'localhost'; $config->dbName = 'example_site'; $config->dbUser = ''; $config->dbPass = ''; $config->dbPort = '3306'; $config->dbCharset = 'utf8mb4'; $config->dbEngine = 'InnoDB'; // Environment overwrite if (file_exists(__DIR__ . '/config.local.php')) { require_once(__DIR__ . '/config.local.php'); } config.local.php: <?php namespace ProcessWire; $config->dbUser = 'example_site_user'; $config->dbPass = 'example_user_pass_123456'; config.local.php is in .gitignore, so never committed, and separate config.local.php files exist on testing / live environments. (I use DeployHQ and this is added as a config file that gets deployed with the rest of the code). To me, the benefits of this approach means that the entire config can be changed depending on the environment, and used to turn things on or off, like debug or advanced mode.1 point
-
New module: OneTimeOnlyCode https://github.com/benbyford/OneTimeOnlyCode Use this module to create codes with urls (or any of string data) and later check a code and its data e.g. to get one time access to content. I built this to send out specific "exclusive" users codes at the end of URLs to new articles where noramlly they would have to log in -> now they can see the content only once and then have to login if they navigate away. I made it only to show the content not any user profile infomation etc when using the code, be warned not to use it to show user information unless you know what you're doing! Codes can have an expiry and uses lazy-cron to cull codes out of day at a set interval (both in checking and elapsed interval for the codes). Check it out!1 point
-
I got tired of looking up fontawesome icon codes all the time... https://marketplace.visualstudio.com/items?itemName=Janne252.fontawesome-autocomplete Using these settings: "fontAwesomeAutocomplete.patterns": ["**/*.php"], "fontAwesomeAutocomplete.insertionTemplate": {"**/*.php": "{name}"}, "fontAwesomeAutocomplete.version": "4" ?1 point
-
I'm not 100 % sure right now, but I think if you don't set a name, Pw takes already care of this problem. Edit: Yep it does, found the code in Pages::___setupNew() protected function ___setupNew(Page $page) { if(!$page->name && $page->title) { $n = 0; $pageName = $this->fuel('sanitizer')->pageName($page->title, Sanitizer::translate); do { $name = $pageName . ($n ? "-$n" : ''); $child = $page->parent->child("name=$name"); // see if another page already has the same name $n++; } while($child->id); $page->name = $name; } //... So just set the title. If the same title appears multiple times, the API generates a name with -1,-2,-3...1 point