Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/29/2020 in all areas

  1. This thread should get you going: https://processwire.com/talk/topic/4437-delete-orphaned-filesimages-from-siteassetsfiles/ Also, once you have everything cleaned up, TracyDebugger (http://modules.processwire.com/modules/tracy-debugger/) has a Page Files panel that will help you keep track of orphaned files/images going forward.
    3 points
  2. $content = ""; foreach ($pages->plus as $key => $projet) { if ($key % 2) { $content .= "A"; } else { $content .= "B"; } } echo $content; Can you try this?
    2 points
  3. ProcessWire 3.0.168 contains 16 commits relative to 3.0.167 and is focused largely on minor issue fixes and improvements, with 8 reported issues fixed and 8 improvements. This week the larger focus was on the ProcessWire modules site. I finally got some serious work done with that this week, and am building good momentum. The front-end of the modules site is being moved into the main ProcessWire site, though the back-end will remain an independent ProcessWire installation. The main ProcessWire site uses multi-instance support to boot the modules site whenever it needs to pull or update data from it. Here's a simplified example: $site = new ProcessWire("/htdocs/modules.processwire.com/"); $items = $site->pages->find("template=module, sort=-created, limit=10"); echo $items->each("<li><a href='/module/{name}/'>{title}</a></li>"); The nice thing is that I’m finding performance to be excellent here, about the same as if I weren’t booting multiple ProcessWire installations. I’m sure there’s some overhead if measured, but it sure isn’t felt. One thing I did learn is that when it comes to pagination, if you want your separately booted site to be aware of the current site’s pagination, you need to tell it the page number. Otherwise the bit of code above will always return the first 10 modules, regardless of pagination number. It seems obvious now, but it took me a minute to realize why. So if pagination is being supported, you'd add this before the $site->pages->find(...) in the example above: $site->input->setPageNum($input->pageNum); For front-end work like this, it's also a good idea to tell your booted site if you want output formatting enabled, so that page titles and such come out entity encoded, for example: $site->pages->setOutputFormatting(true); ...or if you prefer the shorter alias: $site->pages->of(true); One big difference with the new modules directory is on the management side for module authors. This part is powered by LoginRegisterPro so that now you have an account to manage all of your modules within. Further, you have the option of maintaining your module author public profile and protecting your account with PW’s two-factor authentication. That's just for starters. All of this is in the early stages of development, but if the development schedule remains as planned, I’ll be following up with more info over the coming weeks, in addition to the regular core and module updates. Have a great weekend!
    2 points
  4. So I decided to wade into module development and created a wrapper module around ImageOptim, a service that compresses and optimizes images in the cloud. ImageOptim currently handles JPG, PNG and GIF files and, depending on the settings you use, shaves off between 15% and 60% in filesize. Great for bandwidth and great for users, especially on mobile. This module handles the part of uploading images to ImageOptim via their official API, downloading the optimized version and storing it alongside the original image. Download & Info GitHub / Module directory / Readme / Usage Why ImageOptim? There are other image optimization services out there, some of them free, that have outstanding ProcessWire modules. A few things make ImageOptim the best tool for most of my customers: It's not free, i.e. it will probably be around for a while and offers support. However, it's cheaper than some of the bigger competitors like Cloudinary. And it does PNG compression better than any of the free services out there, especially those with alpha channels. Installation Install the module like any other ProcessWire module, by either copying the folder into your modules folder or installing it via the admin. See above for downloads links on GitHub and in the module directory. Requirements To be able to upload images to the service, allow_url_fopen must be set on the server. The module will abort installation if that's not the case. I have only tested the module on ProcessWire 3.x installations. I don't see why it shouldn't work in 2.x, if anyone wants to try it out and report back. ImageOptim account To compress images, you first need to sign up for an ImageOptim account. They offer free trials to try the service. Usage (manual optimization) Images can be optimized by calling the optimize() method on any image. You can pass an options array to set ImageOptim API parameters. $image->size(800,600)->optimize()->url $image->optimize(['quality' => 'low', 'dpr' => 2]) // Set quality to low and enable hi-dpi mode Automatic optimization The module also has an automatic mode that optimizes all image variations after resizing. This is the recommended way to use this module since it leaves the original image uncompressed, but optimizes all derivative images. $image->size(800,600)->url // nothing to do here; image is optimized automatically To change compression setting for single images, you can pass an options array along with the standard ImageResizer options. Passing false disables optimization. $image->size(800, 600, ['optimize' => 'medium']) $image->size(800, 600, ['optimize' => ['quality' => 'low', 'dpr' => 2]]) $image->size(800, 600, ['optimize' => false]) For detailed usage instructions and all API parameters, see the usage instructions on GitHub. Filenames Optimized images will be suffixed, e.g. image.jpg becomes image.optim.jpg. You can configure the suffix in the module settings. Roadmap Asynchronous processing. Not really high on the list. Image variations need to be created anyway, so waiting a few seconds longer on first load is preferable to adding complexity to achieve async optimization. Optimize image variations created by other modules. CroppableImage comes to mind. I don't use any of these, so if somebody wants to help out and submit a pull request — all for it! Add a dedicated page in the setup menu with a dashboard and detailed statistics. ImageOptim's API is very barebones for now, so not sure if that's feasible or even necessary. Stability I've been using this module on production sites for some time now, without hiccups. If you do notice oddities, feel free to comment here or investigate and submit PRs.
    1 point
  5. E-commerce is probably one of Processwire's weakest points in terms of a quick, ready to go integration, although hopefully that will change when Padloper 2 is released, but I was doing some browsing and came across a PHP e-commerce platform Aimeos https://aimeos.org/docs/latest/developer/architecture/ that grabbed my attention with this quote: Has anyone had any experience with it? I'm trying to work out how it would need to be integrated, (currently it supports Laravel, Symfony, and Typo3 off the shelf), but if there's an off-the-shelf open source e-commerce package that can be integrated relatively easily with Processwire, that would be nice.
    1 point
  6. Glad you got it working! That's all of us really - it's more a matter of eliminating possibilities sometimes and debugging what the value of variables that are throwing errors actually are and then looking at what / how those variables are used.
    1 point
  7. thanks so much! It works like a charm now. I did notice the (int) but didn't think to much about it. The problem is my knowledge is a bit all over the place, learning by doing, you know. And I also did try with $fields->get('images'); // some string conversion error or whatever but not with $fields->get('images')->id; // this was the last piece of the puzzle Anyways, thanks again, great module/module-action. I won't even suggest to turn this requirement here into a separate action, I think it's just too simple?
    1 point
  8. I am trying to help here, but you gotta meet me half way ? If you look the code in the action, you'll see that it sanitizes the field as an integer and the options form stores the ID of the field, rather than the name. I'm sure you'll figure it out from that ?
    1 point
  9. @DV-JF Use a try catch block like this: <?php namespace ProcessWire; $menuItemsAsArray = [];// only if use getMenuItems() $menu = ''; $menus = $modules->get('MarkupMenuBuilder'); try { // no error: render menu $menu = "<div>"; $menu .= $menus->render('footer-3', $scnd_options); $menu .= "</div>"; // OR IF USING getMenuItems() //$menuItemsAsArray = $menus->getMenuItems('footer-3'); } catch (\Throwable $th) { //bd($th, 'ERROR'); // get error message (No menu items found! Confirm that such a menu exists and that it has menu items.) $menu = $th->getMessage(); } // if using menu items array if(!empty($menuItemsAsArray)){ // build menu from array }
    1 point
  10. 1 point
  11. No, it doesn't search as a phrase but it does require all of the words to be present in the field, and does not match partial words. So if $q = "red dog" it will match "I have a dog and she loves red frisbees" but it won't match "I have three red dogs". When using the %= operator with multiple words, you will need to explode on spaces and foreach: $q = preg_replace("/\s+/", ' ', trim($q)); // trim and replace multiple spaces with single space $q_words = explode(' ', $q); $selector = "template=product, limit=10"; foreach($q_words as $q_word) { $selector .= ", title|subtitle|summary|body|product_isbn|authors.authors_name%=$q_word"; }
    1 point
×
×
  • Create New...