Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/10/2021 in all areas

  1. It's spring break here and my kids are going back to school next week after being out for more than a year. Since it's a break week, the weather is great, and it's also the last week of the year-long covid break from school, I've spent a little less time at the computer this week. I've focused on some smaller module projects rather than the core. More specifically: posted a major update and refactor of the TextformatterHannaCode module, and a completely rewritten TextformatterVideoEmbed module. While making these updates, I've also made note of and attempted to resolve any reported issues in the GitHub repositories. Next week, it's back to the core, with both issue resolutions and pull requests scheduled for upcoming versions. Next week I also get my 2nd shot of covid vaccine, and I'm told it may slow me down a bit for a day, but will be well worth it. I had a day of tiredness from the 1st shot, but it was greatly outweighed by feelings of gratitude and reduction of worry. I highly recommend it as soon as you can get it, if you haven't already.
    8 points
  2. This module is sort of an upgrade to my earlier ImageToMarkdown module, and might be useful to anyone working with Markdown in ProcessWire. Copy Markdown Adds icons to images and files that allow you to copy a Markdown string to the clipboard. When you click the icon a message at the top left of the screen notifies you that the copying has occurred. Screencast Note: in the screencast an EasyMDE inputfield is used to preview the Markdown. It's not required to use EasyMDE - an ordinary textarea field could be used. Usage: Images When you hover on an item in an Images field an asterisk icon appears on the thumbnail. Click the icon to copy an image Markdown string to clipboard. If the "Description" field is populated it is used as the alt text. You can also open the "Variations" modal for an image and click the asterisk icon to copy an image Markdown string for an individual variation. Usage: Files When you hover on an item in a Files field an asterisk icon appears next to the filename. Click the icon to copy a link Markdown string to the clipboard. If the "Description" field is populated it is used as the link text, otherwise the filename is used. https://github.com/Toutouwai/CopyMarkdown https://processwire.com/modules/copy-markdown/
    6 points
  3. Food Allergens Module A simple List of Food Allergens My needs were to provide a simple list of food allergens for our clients with restaurant related activity. The idea was to simply output the list (to speed up the data entry) without leaving the food menu editing, eg. opening another page in new tab or window. This isn't a perfect solution, but it works fine for my needs and I decided to share the base idea. This could also be easily used to show little notes or short "vademecum", not only for the list of food allergens. --- Main features The basis All moves from a short editing of the module in this tutorial: How to create custom admin pages by @bernhard First of all it creates an empty admin page, with a dedicated permission to let safe-user to see it (this permission has to be created as a new ones, manually or by the module). Once the page is created, I have hooked its behaviour into the ready.php, to show the content (basically a list). A step further With the tips of @bernhard, @Soma (and many others), see here , the magic happens. The new page will be shown as a panel, so editors will not abandon their data entry to have a quick view to the list. A little further Why scroll to the top of the page to click a link? The next step was to create a sticky button only in the food menu pages. Again with a @bernhard tip I moved into the customization of this simple module and the related hook. --- How to use this module After installed, it creates the page /admin/page/allergens/ and the module is to be setted up. The first field is a CKEditor with multi-language. This is the place where to write the informations that will be shown into the page. The next field is a simply text-area where to place a bit of JS that will be appended to the markup of the text (omit the 'script' tags). I also putted a checkbox with a silly statement: this to think at least twice on the safety of the written JS. Now comes the first way to display the link to the page Field Note with Link. Enable and save it. The module will display a new row with 4 selects (1 standard and 3 ASM): View mode (to show the page as Panel or as Modal PopUp); Templates to select: select one or more and save before proceed, so the asm-select of the pages will be populated showing all the pages of the selected templates. Pages to select: also here select at least one and save before proceed to populate the asm-select for fields only with the ones that belong to the selected pages. Select the fields where to place the note and save again. That's all: now you will find into the notes of the selected fields the link "See the List of Allergens". At the same way, the option for the sticky button, but with a plus The field select is obviously unnecessary, but you could play with the last row: the inline styles to fix your sticky button where you like. Here you could set the sticky position of the <div> and the absolute ones of the <a>. Video Explanation In these screencasts you could see a custom JS that show a "copy" button near a "hanna-code" call. This because I've set a specific one for each allergen to show up a tooltip in the front end. Registrazione #33.mp4 Registrazione #34.mp4 --- Last but not the least Actually it works fine for my needs, even if it's much improvable: I'm working on the permissions creation, the uninstall section, a separate configs and defaults and how to include the hook into the module leaving free the ready.php. According to a simpler uninstall. Also I would make the link text as a dynamic text field, so it will be more flexible. I always learn a lot here, so I would share my code for whom it could be interested. I removed the hanna code references, but I provide you the html list of the allergens, English and Italian too, so you can paste them into the "source" of the CKEditor field to have a ready to use module. Obviously you are free to modify the code as per your needs. Please, keep in mind that I'm not a pro coder and I beg your pardon for my verbosity (speaking and coding). ? I hope be helpful or for inspiration. Bye ready.phpList-ITA.htmlList-ENG.htmlAllergens.module README.md
    5 points
  4. Thanks for sharing this. ? Another possible way to approach this is to use a single Hanna tag for all allergens and then use Hanna Code Dialog to create an interface where a site editor can select allergen types by label. You could use a page per allergen type and use the (multi-language?) title field for the label and an integer field for the allergen number. Then use a hook to set the options for the dialog. $wire->addHookAfter('HannaCodeDialog::buildForm', function(HookEvent $event) { // The Hanna tag that is being opened in the dialog $tag_name = $event->arguments(0); // The form rendered in the dialog /* @var InputfieldForm $form */ $form = $event->return; if($tag_name === 'allergen') { /* @var InputfieldCheckboxes $f */ $f = $event->wire('modules')->InputfieldCheckboxes; $f->name = 'type'; $f->id = 'type'; $f->label = 'Type'; foreach($event->wire()->pages->find("parent=/references/allergens/") as $allergen) { $f->addOption($allergen->allergen_number, $allergen->title); }; $form->add($f); } }); Or maybe if you are using a Repeater for your menu items you don't need Hanna Code and could just use a Page Reference field to select allergen pages per menu item.
    5 points
  5. I've been meaning to revise PageimageSrcset for a while now, to remove some features that I felt were unnecessary and to implement a better rendering strategy. The result is PageimageSource. What does it do? It provides a configurable srcset method/property for Pageimage It allows WebP to be enabled for images it generates. It allows Pageimage:render() to return a <picture> element It provides a Textformatter that replaces <img> elements with the output of Pageimage:render() Although it is based on a current module, this should still be considered beta and not used in production without a prior development stage. Here's the README: PageimageSource Extends Pageimage with a srcset property/method plus additional rendering options. Overview The main purpose of this module is to make srcset implementation as simple as possible in your template code. For an introduction to srcset, please read this Mozilla article about responsive images. Installation Download the zip file at Github or clone the repo into your site/modules directory. If you downloaded the zip file, extract it in your sites/modules directory. In your admin, go to Modules > Refresh, then Modules > New, then click on the Install button for this module. ProcessWire >= 3.0.165 and PHP >= 7.3 are required to use this module. Configuration To configure this module, go to Modules > Configure > PageimageSource. Default Set Rules These are the default set rules that will be used when none are specified, e.g. when calling the property: $image->srcset. Each set rule should be entered on a new line, in the format {width}x{height} {inherentwidth}w|{resolution}x. Not all arguments are required - you will probably find that specifying the width is sufficient for most cases. Here's a few examples of valid set rules and the sets they generate: Set Rule Set Generated Arguments Used 320 image.320x0-srcset.jpg 320w {width} 480x540 image.480x540-srcset.jpg 480w {width}x{height} 640x480 768w image.640x480-srcset.jpg 768w {width}x{height} {inherentwidth}w 2048 2x image.2048x0-srcset.jpg 2x {width} {resolution}x How you configure your rules is dependent on the needs of the site you are developing; there are no prescriptive rules that will meet the needs of most situations. This article gives a good overview of some of the things to consider. When you save your rules, a preview of the sets generated and an equivalent method call will be displayed to the right. Invalid rules will not be used, and you will be notified of this. WebP If enabled, WebP versions of the image and srcset variations will be generated and these will be returned by Pageimage::srcset(). As with the default implementation, the image with the smaller file size is returned. In most cases this is the WebP version, but sometimes can be the source. Make sure to experiment with the quality setting to find a value you find suitable. The default value of 90 is fine, but it is possible that lower values will give you excellent kB savings with little change in overall quality. For more information on WebP implementation please read the blog posts on the ProcessWire website. Rendering These settings control how the output of Pageimage::render() is modified. Use Lazy Loading? When enabled this adds loading="lazy" to the <img> attributes. It is useful to have this on by default, and you can always override it in the options for a specific image. Use the <picture> element? When enabled, the <img> element is wrapped in a <picture> element and <source> elements for original and WebP variations are provided. This requires WebP to be enabled. For more information on what this does, have a look at the examples in Pageimage::render() below. Remove Variations If checked, the image variations generated by this module are cleared on Submit. On large sites, this may take a while. It makes sense to run this after you have made changes to the set rules. Please note that although the module will generate WebP versions of all images if enabled, it will only remove the variations with the 'srcset' suffix. Usage Pageimage::srcset() // The property, which uses the set rules in the module configuration $srcset = $image->srcset; // A method call, using a set rules string // Delimiting with a newline (\n) would also work, but not as readable $srcset = $image->srcset('320, 480, 640x480 768w, 1240, 2048 2x'); // The same as above but using an indexed/sequential array $srcset = $image->srcset([ '320', '480', '640x480 768w', '1240', '2048 2x', ]); // The same as above but using an associative array // No rule checking is performed $srcset = $image->srcset([ '320w' => [320], '480w' => [480], '768w' => [640, 480], '1240w' => [1240], '2x' => [2048], ]); // The set rules above are a demonstration, not a recommendation! Image variations are only created for set rules which require a smaller image than the Pageimage itself. This may still result in a lot of images being generated. If you have limited storage, please use this module wisely. Pageimage::render() This module extends the options available to this method with: srcset: When the module is installed, this will always be added, unless set to false. Any values in the formats described above can be passed. sizes: If no sizes are specified, a default of 100vw is assumed. lazy: Pass true to add loading=lazy, otherwise false to disable if enabled in the module configuration. picture: Pass true to use the <picture> element, otherwise false to disable if enabled in the module configuration. Please refer to the API Reference for more information about this method. // Render an image using the default set rules // WebP and lazy loading are enabled, and example output is given for <picture> disabled and enabled echo $image->render(); // <img src='image.webp' alt='' srcset='image.jpg...' sizes='100vw' loading='lazy'> /* <picture> <source srcset="image.webp..." sizes="100vw" type="image/webp"> <source srcset="image.jpg..." sizes="100vw" type="image/jpeg"> <img src="image.jpg" alt="" loading="lazy"> </picture> */ // Render an image using custom set rules echo $image->render(['srcset' => '480, 1240x640']); // <img src='image.webp' alt='' srcset='image.480x0-srcset.webp 480w, image.1240x640-srcset.webp 1240w' sizes='100vw' loading='lazy'> /* <picture> <source srcset="image.480x0-srcset.webp 480w, image.1240x640-srcset.webp 1240w" sizes="100vw" type="image/webp"> <source srcset="image.480x0-srcset.jpg 480w, image.1240x640-srcset.jpg 1240w" sizes="100vw" type="image/jpeg"> <img src="image.jpg" alt="" loading="lazy"> </picture> */ // Render an image using custom set rules and sizes // Also use the `markup` argument // Also disable lazy loading // In this example the original jpg is smaller than the webp version echo $image->render('<img class="image" src="{url}" alt="Image">', [ 'srcset' => '480, 1240', 'sizes' => '(min-width: 1240px) 50vw', 'lazy' => false, ]); // <img class='image' src='image.jpg' alt='Image' srcset='image.480x0-srcset.webp 480w, image.1240x0-srcset.webp 1240w' sizes='(min-width: 1240px) 50vw'> /* <picture> <source srcset="image.480x0-srcset.webp 480w, image.1240x0-srcset.webp 1240w" sizes="(min-width: 1240px) 50vw" type="image/webp"> <source srcset="image.480x0-srcset.jpg 480w, image.1240x0-srcset.jpg 1240w" sizes="(min-width: 1240px) 50vw" type="image/jpeg"> <img class='image' src='image.jpg' alt='Image'> </picture> */ // Render an image using custom set rules and sizes // These rules will render 'portrait' versions of the image for tablet and mobile // Note the advanced use of the `srcset` option passing both `rules` and image `options` // WebP is disabled // Picture is disabled echo $image->render([ 'srcset' => [ 'rules' => '320x569, 640x1138, 768x1365, 1024, 1366, 1600, 1920', 'options' => [ 'upscaling' => true, 'hidpi' => true, ], ], 'sizes' => '(orientation: portrait) and (max-width: 640px) 50vw', 'picture' => false, ]); // <img src='image.jpg' alt='' srcset='image.320x569-srcset-hidpi.jpg 320w, image.640x1138-srcset-hidpi.jpg 640w, image.768x1365-srcset-hidpi.jpg 768w, image.1024x0-srcset-hidpi.jpg 1024w, image.1366x0-srcset-hidpi.jpg 1366w, image.1600x0-srcset-hidpi.jpg 1600w, image.jpg 1920w' sizes='(orientation: portrait) and (max-width: 768px) 50vw' loading="lazy"> TextformatterPageimageSource Bundled with this module is a Textformatter largely based on TextformatterWebpImages by Ryan Cramer. When applied to a field, it searches for <img> elements and replaces them with the default output of Pageimage::render() for each image/image variation. Assuming a default set of 480, 960 and lazy loading enabled, here are some examples of what would be returned: Example <figure class="align_right hidpi"> <a href="/site/assets/files/1/example.jpg"> <img alt="" src="/site/assets/files/1/example.300x0-is-hidpi.jpg" width="300" /> </a> </figure> WebP enabled <figure class="align_right hidpi"> <a href="/site/assets/files/1/example.jpg"> <img alt="" src="/site/assets/files/1/example.300x0-is-hidpi.webp" width="300" srcset="/site/assets/files/1/example.300x0-is-hidpi.webp 480w" sizes="100vw" loading="lazy" /> </a> </figure> <picture> enabled <figure class="align_right hidpi"> <a href="/site/assets/files/1/example.jpg"> <picture> <source srcset="/site/assets/files/1/example.300x0-is-hidpi.webp 480w" sizes="100vw" type="image/webp"> <source srcset="/site/assets/files/1/example.300x0-is-hidpi.jpg 480w" sizes="100vw" type="image/jpeg"> <img alt="" src="/site/assets/files/1/example.300x0-is-hidpi.jpg" width="300" loading="lazy" /> </picture> </a> </figure> Because the variation is small - 300px wide - the srcset only returns the source image variation at the lowest set width (480w). If the source image was > 1000px wide, there would be a variation at both 480w and 960w. PageimageSrcset This module is built upon work done for PageimageSrcset, which can be considered a first iteration of this module, and is now deprecated. Migration PageimageSource is a simplified version of PageimageSrcset with a different approach to rendering. Most of the features of the old module have been removed. If you were just using $image->srcset(), migration should be possible, as this functionality is essentially the same albeit with some improvements to image variation generation.
    3 points
  6. This is great @ryan - Quick question. Digital Oceon doesn't automatically balance between all the read only nodes as RDS does. Is it possible or is it on the roadmap to allow adding multiple nodes in PW and PW distributes between that list of nodes. Could be as simple as an array of dbReaders, with PW randomly selecting from the array for each read request. Or round robin. That would allow it to be much more flexible setup and support self hosting read replicas for example. Otherwise fantastic work this is great.
    3 points
  7. @markus_blue_tomato Sorry to hear that, I hope they have it available soon. I figured we'd be the last to get it here because the for-profit healthcare system in the US doesn't often lend itself well to public health, unless you are wealthy. (Just getting a covid test was $400). Luckily it seems the vaccine isn't being handled by the healthcare companies, and it's free. My parents got their vaccine at an appliance store drive-through, my wife got hers at the grocery store, and I got mine at the office of some technology company in our town square. That might sound sketchy but they are all legitimate and it seems to be working well for once.
    3 points
  8. Thanks for noticing! I fixed the typo in the git repo, should be updated in the PW module repo soon. Hm, I'm looking into this problem. Which version of PrivacyWire are you using?
    2 points
  9. Congratulations for your achievements ? I think https://github.com/BitPoet/ProcessCKInlineComplete could also be a great option? Just type @... and get suggested allergens!
    2 points
  10. Thanks for showing those modules some love Ryan - much appreciated!
    2 points
  11. If you look at the code in Migrator you'll see that I store images in the migration zip package under a path that matches the path of the page they are associated with, so for example, an image asociated with a blog post might look something like this: Page path: /blog/my-latest-blog/ Images for that pos: zippackage/blog/my-latest-blog/image-1.jpg, zippackage/blog/my-latest-blog/image-2.jpg, etc Then when the migration package is installed on the other site and the new page ID for blog/my-latest-blog/ is determined, the images are then added to that page and installed into the /assets/files/xxxx that matches that new ID. There is so much to consider with all this stuff, but if you run through a full migration of a tree of pages using Migrator you'll see how it stores all this stuff in the zip and how it modifies the paths in RTE fields to match the path of the page and then back to the /assets/files path again.
    1 point
  12. @MarkE - also, just a reminder about updating the path to images embedded in RTE fields. You might find some useful code for that starting here: https://github.com/adrianbj/ProcessMigrator/blob/b327626606bcdc9cc6c74bd00f9e9d2bcd2cae50/ProcessMigrator.module#L2588
    1 point
  13. Thanks @Robin S and @horst - unfortunately I am still getting this timeout behaviour, even with your approach horst, so I have no idea ?
    1 point
  14. Hi, ProcessWire 3.0.175 + PrivacyWire 104. On this occasion I wish to thank you for the really helpful module contribution and all your support!
    1 point
  15. Hi, honestly, i've build a lot of sliders in websites with pw, depending of what you're using as js, there are a lot of plugins out there, vanilla, jquery or zepto (i love the vegas one that runs with jquery or zepto ? ) simple ones are even easy to build self made with vanilla js when it comes to a simple admin for it, depending of what you're going to do, image slider with just a simple legend/text, an image field will do the job using the description for the text part if you want to go a little further, just use a repeater... image field(s) in each item, text, richt text, you'll not run into any limit in both cases your user can order the slides dragging the items with their mouse, hard to find something easier ? have a nice day
    1 point
  16. What I have found out is that sending WireHttp requests as https lacks of embedding the ssl certificate things and therefor results in false responses. When I explicitly use http and NOT https, then this code seems to work fine, as it sends exactly the same headers like the browser of the logged in session does: $wire->session->set('wirehttprequestheaders', getallheaders()); $url = 'http://' . $wire->config->httpHost . '/cli.php'; $http = new WireHttp(); foreach($wire->session->get('wirehttprequestheaders') as $header => $value) { if('Host' == $header) continue; $http->setHeader($header, $value); } $response = $http->post($url); // or ->get() or send() if($response !== false) { echo '<pre>'; var_dump($response); } else { echo '<pre>'; var_dump($http->getError()); } My cli.php for testing looks like this: <?php namespace ProcessWire; include('./index.php'); if($wire->user->isSuperuser()) { echo '<pre>'; var_dump(getallheaders()); } else { die('NO ACCESS'); } I never got this timeout behave. Only false or true responses, but always within a second or less. Don't know if this is of any help.
    1 point
  17. Thanks Bernhard, your advice spurred me not to settle. I will surely give a look at the solution of BitPoet, it sounds very interesting... P.S. Everyday I discover a mine of treasures...
    1 point
  18. In this example the starting quote at the type attribute is missing: <script type="text/plain" data-type="text/javascript" data-category="external_media" class="require-consent">...</script> In your example: Does it work with the quotation mark?
    1 point
  19. Hi Robin, thanks for your reply and your suggestions. I totally missed your HC dialogue: I can't wait to study that module, I will look in depth asap ? And the page reference (yes, I use a repeater) is also a great idea ... I hadn't thought of that. Tks!
    1 point
  20. @ryan I was pleasantly surprised to see updates for these when checking Processwire Upgrades module, which I would also love to see an update for removing older official repositories and adding support for Pro modules. I installed the updates on a site (well, uninstalled and reinstalled YouTube as per instructions). Great updates. It would be great if you could add social embeds to a separate module as I think YouTube embeds is perfect at what it does. Glad to hear the vaccinations are going well there. I am not eligible yet in the UK due to age and good health but my family have all had either 1 or 2 jabs which is the main thing. Stay safe everybody.
    1 point
  21. Page Reference Default Value Most ProcessWire core inputfield types that can be used with a Page Reference field support a "Default value" setting. This module extends support for default values to the following core inputfield types: Page List Select Page List Select Multiple Page Autocomplete (single and multiple) Seeing as these inputfield types only support the selection of pages a Page List Select / Page List Select Multiple is used for defining the default value instead of the Text / Textarea field used by the core for other inputfield types. This makes defining a default value a bit more user-friendly. Note that as per the core "Default value" setting, the Page Reference field must be set to "required" in order for the default value to be used. Screenshot https://github.com/Toutouwai/PageReferenceDefaultValue https://modules.processwire.com/modules/page-reference-default-value/
    1 point
  22. @adrian, I've tried but unfortunately I haven't had any success with getting the titles of admin pages. ? I turned off a couple of $config settings while I was testing: $config->sessionFingerprint = 0; $config->sessionChallenge = false; And I used curl directly rather than WireHttp to keep it simple. The problem is that as soon as you set the "wire" cookie value... curl_setopt($ch, CURLOPT_COOKIE, "wire={$input->cookie->wire}"); ...PW just doesn't give any response and curl times out. It doesn't matter if you try and get a PW admin page or a frontend page. I thought it might have been an endless redirect situation but when I get the transfer information with curl_getinfo it looks like no redirects are occurring so it seems that's not the problem. I'd love to know why PW doesn't respond but I don't know how to debug this any further. Unless anyone can make a breakthrough with this maybe it will be a matter of manually setting titles for any links to pages that require a logged-in user. Not a great hardship. ?
    1 point
  23. Thanks. The v0.3.0 update to HannaCode is actually a major refactoring of the module so there were a few things in HannaCodeDialog that needed updating for compatibility. The new v0.4.0 of HannaCodeDialog should be compatible with HannaCode v0.3.0 and it requires HannaCode >= v0.3.0.
    1 point
  24. Just tried activated it for https://corporate.blue-tomato.com/ which runs on Digital Ocean. Seems it works well.
    1 point
  25. TextformatterHannaCode is a nice multi-purpose tool for tasks like that. If manually addressing the correct files becomes an issue, then HannaCodeDialog is also worth a look. It integrates with CKEditor and lets you assemble small UIs for your Hanna codes.
    1 point
  26. I hadn't developed a website for a while, but here we are. It's a very simple minimalist website to showcase the latest work of Dominican Artist Patricia Abreu Mota. Site: https://patriabreu.com Modules: Procache ❤️ Seo Maestro Profiler Pro Lister Pro ProcessRedirects
    1 point
  27. Thanks for your input @horst - turns out this error is new to PHP8 because they changed the behavior of the shutup operator so that it no longer silences fatal errors. I have filed an issue for Ryan with a working solution here: https://github.com/processwire/processwire-issues/issues/1299
    1 point
  28. Ah, ok. Thanks for the explanation. The pages-approach seemed to me like a nasty workaround, but when this is the way to go, i'll do it. Also thanks for the module. I stumbled over it some time ago, but didn't saw it's potential.
    1 point
  29. Field label is not in the page field value, you have to get it through the field itself. echo $fields->get("body")->label;
    1 point
×
×
  • Create New...