Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/29/2018 in all areas

  1. Inspired by the "max megapixels" option for the client-side image resizer, I made a simple module that adds target megapixel resizing for Pageimages. Image Megapixels A module for ProcessWire CMS/CMF. Adds methods to Pageimage objects useful for resizing to a target megapixel value. Example use You are creating a lightbox gallery of images with different aspect ratios. For the enlargements, rather than setting a fixed maximum width or height you want all the enlargements have the same size in terms of area, allowing a panoramic image to be wider than a square image, for instance. Another use case is sizing a gallery of sponsor logos. The supplied logos are different aspect ratios but you need to ensure the logos are sized so each has equal prominence on the page. The effect of resizing three different aspect ratios by the same megapixel target value can be seen in the screenshot below: Installation Install the Image Megapixels module. API // basic usage $pageimage = $pageimage->megapixels(float $megapixels); // usage with all arguments $pageimage = $pageimage->megapixels(float $megapixels, array $options = []); Example: foreach($page->images as $image) { echo "<img src='$image->megapixels(0.8)->url' alt='$image->description'>" } If needed you can supply an array of options for Pageimage::size() as a second argument. Getting dimensions If you just want to get the height and width dimensions needed to size an image to the given number of megapixels you can use the Pageimage::megapixelsDimensions() method that this module also adds. It returns an array with width and height as keys. Example of how this could be used to output a gallery of logos: foreach($page->logos as $logo) { $dimensions = $logo->megapixelsDimensions(0.01); $width = $dimensions['width']; $height = $dimensions['height']; $width2x = $width * 2; $height2x = $height * 2; echo "<img src='{$logo->size($width, $height)->url}' srcset='{$logo->size($width, $height)->url} 1x, {$logo->size($width2x, $height2x)->url} 2x' alt='Logo' width='$width' height='$height'>"; } https://github.com/Toutouwai/ImageMegapixels https://processwire.com/modules/image-megapixels/
    6 points
  2. Almost one click - check out the Batch Child Editor module: http://modules.processwire.com/modules/batch-child-editor/ - either Edit or Replace mode. You could also code an API snippet and store it in the Tracy Console panel snippets list - just run it from the parent page (either on the frontend, or while editing the parent page in the backend - the console will get $page as the page being edited): Or you could use that code in an AdminActions (http://modules.processwire.com/modules/process-admin-actions/) action.
    5 points
  3. From a security standpoint, ProcessWire will not allow you to directly access PHP files in a number of its protected folders (including the site/templates folder) unless that file is a template file. You can read more about it here. In that thread you'll also find a number of workarounds. Only if it's outside PW directories. See option #1 in the post I linked to above. This means you won't have access to PW's API, unless you bootstrap it, which might not be worth the effort, if all you want to avoid is creating a page .. Many people often use option #3. Post to self (same page) and include your add_client.php in that page's template file (e.g., require_once('/path/to/add_client.php/')).
    4 points
  4. I have just been playing around with the "Selector Queries" section of the Tracy Debug Mode panel. Now it adds the SQL Query column to show you the query that was used for each of the selectors called in generating the current page. I am not yet convinced it's perfect for all selectors, so I haven't committed it yet, but if anyone would like to try it out, I can either post here or push to a dev branch. Also, any thoughts on this? How useful it is, and if you have ideas for making it more useful.
    4 points
  5. Just a quick note. Whilst it's ok to do a "Select * from ..." query whilst you're debugging or developing, you shouldn't use the * clause in your final production version. Why? 1) Efficiency. You may not need all the fields from the table(s) you're selecting from. Reducing the fields will make your query return quicker. 2) If 1 of the underlying tables change in the future, "Select *" might be masking some unintended consequences. Listing individual fields would have made it easier for future maintenance and spot any potential bugs. I've definitely had to fix a few stored procedures in my lifetime where a structural change to a table resulted in tracking down why the stored procedures stopped working suddenly.
    3 points
  6. For reference, copy&paste for images is finally in the core: https://processwire.com/blog/posts/pw-3.0.87/
    3 points
  7. From https://icongr.am/simple/processwire.svg
    2 points
  8. I'm writing a tutorial on using tracy soon, started it the other day. It's a chance to finally get my feet wet with it myself, and to share whatever I learn along the way. I'd give the dev branch a go.
    2 points
  9. Maybe not, but as @szabesz and I discussed, it's also not good to have a field that is too narrow to accommodate the length of the number that needs to be entered. I think I'd actually prefer the subfields to be on separate lines (wrapped) if the screen is too narrow. Anyone else have any better suggestions?
    2 points
  10. Hi gerald, another Austrian here Adrian's modules are such great timesavers, indeed. But be careful using $pages->delete() as this is irreversible! You can also use $pages->trash() to have one extra step and then click on "empty trash" if you are sure everything is fine.
    2 points
  11. 3 solutions in 5 minutes. Amazing. Thanks Adrian
    2 points
  12. Loosely related request in GitHub: https://github.com/processwire/processwire-requests/issues/56. I've also been having a number problems with the current behaviour, but I hope that one day we can get past this whole filename mangling silliness Edit: just realized that you're trying to do pretty much exactly the same thing as I was when I last encountered this issue. If you do find an elegant way around this, please let me know as well
    2 points
  13. Just to clearify: I think the first aim of this inputfield should be a clean UI for entering business hours in an easy way (and in this case you made a great job). The next step is to provide the API calls to get the opening times for each day (like you have also done). So every opening time of each day can be indivdually outputted, formatted, styled or used for further PHP operations. Offering some nice additional API-calls for getting some additional information (whether it is open or not) is great, but can be achived with other libraries or PHP coding too and should only be an addon (not really necessary). So an additional input field for opening times on natural holidays is enough. We can use the value to make further operations (fe to check if this day is a nat. holiday or not by using fe. the Yasumi library) -> thats up to us as site developers and should not be an issue you have to deal with. Not everyone needs this feature. Best regards
    2 points
  14. @Robin S This is a GREAT explanation and is super appreciated. I totally get it... and now understand that some things don't work with in-memory selectors (modifying a PageFinder, in theory) – again I really appreciate your explanation.
    2 points
  15. The documentation could be clearer in this regard, and I'm probably oversimplifying here, but there two basic categories of selector usage in PW. 1. Methods that use the PageFinder class - common ones would be $pages->find($selector), $pages->get($selector), $page->children($selector). Also find/get selectors for $users. Those are the ones that spring to mind, although there might be a few more. These methods do a database query behind the scenes. 2. All other methods that accept a selector, for example $some_pagearray->find(), which is actually WireArray::find(). These methods do not query the database but work on items that are in memory. There are differences in the ways that these two categories of selector usage are implemented. Some things work in a PageFinder selector that don't work in an in-memory selector. The documentation for Selectors seems to be assuming the reader is interested in PageFinder selectors because there are code examples there that won't work with in-memory selectors. There isn't any definitive list of the differences (that I know of), but here are some things that I have found do not work with in-memory selectors (but do work with PageFinder selectors): 1. Datetime values as strings, e.g. "some_datetime_field>today" 2. Page statuses as strings, e.g. "status!=hidden" 3. OR groups In a perfect world selectors would work the same everywhere and you wouldn't have to think about it. There's an open request for this here.
    2 points
  16. Hi @abdus, Do you know if it's possible to use this technique to add config fields such as minWidth and maxWidth to the template context for InputfieldImage? My first attempt isn't working: // Add more image config fields to template context $this->addHookMethod('InputfieldImage::getConfigAllowContext', function (HookEvent $e) { $allowables = ['minWidth', 'minHeight', 'maxWidth', 'maxHeight']; $e->return = array_merge($e->return, $allowables); }); I have a feeling that the reason this doesn't work is because those config fields are inside a fieldset. Adding the whole fieldset would be fine, but the problem is that the fieldset doesn't have a name to add to getConfigAllowContext(). Any ideas? ----- EDIT: have sussed it out. I used another hook to give names to those fieldsets. // Give names to image config fieldsets $wire->addHookAfter('InputfieldImage::getConfigInputfields', function(HookEvent $event) { /* @var InputfieldWrapper $wrapper */ $wrapper = $event->return; $f = $wrapper->getChildByName('maxWidth'); $fieldset = $f->parent; $fieldset->name = 'maxDimensions'; $f = $wrapper->getChildByName('minWidth'); $fieldset = $f->parent; $fieldset->name = 'minDimensions'; }); // Add more image config fields to template context $this->addHookMethod('InputfieldImage::getConfigAllowContext', function (HookEvent $e) { $allowables = ['maxDimensions', 'minDimensions']; $e->return = array_merge($e->return, $allowables); });
    2 points
  17. Presentation Originaly developped by Jeff Starr, Blackhole is a security plugin which trap bad bots, crawlers and spiders in a virtual black hole. Once the bots (or any virtual user!) visit the black hole page, they are blocked and denied access for your entire site. This helps to keep nonsense spammers, scrapers, scanners, and other malicious hacking tools away from your site, so you can save precious server resources and bandwith for your good visitors. How It Works You add a rule to your robots.txt that instructs bots to stay away. Good bots will obey the rule, but bad bots will ignore it and follow the link... right into the black hole trap. Once trapped, bad bots are blocked and denied access to your entire site. The main benefits of Blackhole include: Bots have one chance to obey your site’s robots.txt rules. Failure to comply results in immediate banishment. Features Disable Blackhole for logged in users Optionally redirect all logged-in users Send alert email message Customize email message Choose a custom warning message for bad bots Show a WHOIS Lookup informations Choose a custom blocked message for bad bots Choose a custom HTTP Status Code for blocked bots Choose which bots are whitelisted or not Instructions Install the module Create a new page and assign to this page the template "blackhole" Create a new template file "blackhole.php" and call the module $modules->get('Blackhole')->blackhole(); Add the rule to your robot.txt Call the module from your home.php template $modules->get('Blackhole')->blackhole(); Bye bye bad bots! Downloads https://github.com/flydev-fr/Blackhole http://modules.processwire.com/modules/blackhole/ Screen Enjoy
    1 point
  18. Since I was stuck to my flat today I took up a wish and rolled a Process module / CKEditor plugin combo that adds @-autocomplete like the mentions here in the forum to CKEditor fields. It's configurable, but only in module settings for now, the positioning of the select list is quite off and there's still some visual work to be done, so it is in early alpha state. Nonetheless, if you want to take a look, here it is: https://github.com/BitPoet/ProcessMention After installation, you may want to look into the "Additional selector" entry in the module's settings. You will most likely want to limit results to certain templates there. Edit: Updated to version 0.0.30 with fixed positioning of the dropdown. Edit2: Settings are configurable in field context now. If pwmentions is enabled, the according settings are shown on the "Input" tab.
    1 point
  19. Today I had an idea and wanted to try out if that could work... A little later I had a little module as a working prototype and I want to share it with you to start some discussion: Idea: The idea is to have a simple interface that provides some helpers for copying/modifying/deleting elements in any HTML page. For now it is bundled to processwire but generally it would be possible to use this tool combined with any HTML that you provide. Why? I think that mockups can really speed up development and - maybe even more important - can also serve as a tool for better communication between us and our clients. There are several tools for this usecase but all that I know (like https://pencil.evolus.vn/ ) have a totally different look and feel than the final software has. So I thought why not use the look and feel of ProcessWire when developing something for ProcessWire? I've built some simple mockups sometimes with my browsers devtools and this works - but it is not really fast (and therefore not fun). Thats why I started this module today. Usage: After installation the module monitors your mouse and highlights all hovered elements inside the #main div. Then you have several keyboard shortcuts: c --> copy element r --> remove element arrow left --> previous sibling arrow up --> parent element arrow right --> next sibling arrow down --> first child e --> edit content with ckeditor ctrl + enter --> save edit Quite selfexplaining, isn't it? Roadmap/Vision: Save/Load For now the module does not save anything. You can modify content as you like and then do a screenshot, but of course it would be great to save your mockups somewhere. And continue work afterwards. Undo/Redo UI-Element Library It would be great to have a sidebar with common pw elements like inputfields and buttons to add via click to your mockup. Copy feature from other sites For example you could copy markup from any other website (like the UIKit docs) and paste that markup to your mockup. Or you could open another site in the pw backend that has UI elements that are similar to your needs and just copy them over. Use it with any HTML The module could be packed into a single JS file and then be used to modify any HTML content (like themes from themeforest or the like). This would be an awesome tool for creating quick mockups of any page, moving around elements, copying things, removing items, changing texts etc. Download: You can download the module here: https://gitlab.com/baumrock/RockMockup (have a look at the code, it's really really simple and everybody is welcome to contribute!) Use ProcessWire Kickstart for a One-Click-Installation: <?php $password = $this->randomPassword(); return [ 'pw' =>'https://github.com/processwire/processwire/archive/dev.zip', 'profile' => 'site-default', 'settings' => [ 'timezone' => 368, // vienna 'dbName' => 'yourdbname', 'dbUser' => 'root', 'dbPass' => $this->randomPassword(), 'admin_name' => 'youradminurl', 'username' => 'youradminusername', 'userpass' => $password, 'userpass_confirm' => $password, //'dbTablesAction' => 'remove', // overwrite existing tables? ], 'recipes' => [ function() { $this->msg('Installing RockMockup...'); $this->installModule('RockMockup', 'https://gitlab.com/baumrock/RockMockup/repository/master/archive.zip'); $this->succ('RockMockup installation completed'); }, ], ]; What do you think? Would you use such a tool? Do you maybe know any existing tools that do a similar thing?
    1 point
  20. I am developing a SEO module with the latest industry standard. I want to upload some images such as logos and used by the module as default setting, while everything is configurable inside the module config page. I know the fact that module configuration page is not allowed to have file/image upload field due to the module fields are only inputfields but no fieldtypes. I would like to adopt an approach to solve this issue. The approach is that, in module installation, I create a page somewhere inside admin with file/image field. And then inside the module config page, the needed fields can be referenced and rendered for image upload. Any similar modules has used similar approach? This approach can also be used for complex fields like repeater field for hreflang, open graph and twitter card too. I don't know if the above setup is possible. Please feel free to share any thoughts or advise another approach.
    1 point
  21. Yes I understand 101% now! I thought it was a core plugin... Can't wait to have the code up and running I'm on 50% updating... 50% works This works <img src='{$page->mosaic_photo_2->eq(0)->getCrop('thumbnail')->url}' alt='{$page->mosaic_photo_2->description}' /></a></div>";} This not <img src='{$child->overviewimg->eq(0)->getCrop('thumbnail')->url}' alt='$child->title'>
    1 point
  22. @lpa - You could replace this module with https://github.com/rolandtoth/AdminOnSteroids . See https://github.com/rolandtoth/AdminOnSteroids/wiki/FieldAndTemplateEditLinks
    1 point
  23. One more option, but requires a pro module. Lister Pro has a delete/trash action in its set of bundled actions. I use this one a lot.
    1 point
  24. @lpa - I have just committed another update - turns out my initial fix broke the standard form approach. The new version works with both. Because of the breaking changes, I have committed it to the dev branch (https://github.com/adrianbj/PageProtector/tree/dev) for now. I would really appreciate it if others using this module could please try this new version. The only change you should need to make is if you are using the custom Login Template option - you will need to change $loginForm to $page->loginForm I'll push this dev version to master once there's been a little time for others to test it.
    1 point
  25. I am not sure I quite understand the question Anything you run in the Console panel will do whatever it is meant to do, so if you run that bit of API code, the pages will be deleted. As for the trash - there isn't any real need to empty that though. I do myself at times because I like things clean, but there isn't any actual need to.
    1 point
  26. It depends how you want to use these 3 links in your template(s). You could just as well use a textarea field, and put each URL on a new line. Or you could store links as pages, and use a page references with multiselect. The latter approach would be wise if a link can be used more than once, and has the advantage that you only need to change the link in once place if you come across a broken link sometime in the future.
    1 point
  27. Merely curious, but I was wondering why you don't handle the request with the same page (action="./") ?
    1 point
  28. Just wanted to say that I really love the new copy&paste feature in ckeditor. Really a great timesaver and so much more comfortable to work with!
    1 point
  29. I believe you can do it like this in your config.php on an individual option basis: $config->imageSizerOptions('quality', 10); $config->imageSizerOptions('cropping', 'north'); ..and so on; this doesn't override any of the other defaults.
    1 point
  30. You cannot post to nothing . You have to post your client-request to something server-side to handle that request. That something can be a module page or a 'normal' (hidden, in admin, etc) page. A URL Segment alone won't work. The name gives it away. Segment of a URL. A URL points somewhere. In ProcessWire, it points to a page. So, yes, you will need a page somewhere in the system.
    1 point
  31. There's some discussion of this and related issues here but it doesn't look promising...
    1 point
  32. Did you try composer create-project processwire/processwire dev-dev --stability=dev ? Seems like the latest dev version is called "dev-dev". The download worked, but I didn't install it. Where is the PW version number usually mentioned ?
    1 point
  33. Thanks @rick, feel like I'm channelling Thomas Edison - "I have not failed. I've just found 10000 ways that won't work." Tried everything combination I can think of and now very tired. Have posted in the Google EB support group but not hopeful of an answer. Maybe with a clear head tomorrow... Appreciate your suggestions
    1 point
  34. To get a "quote" how useful it maybe for a specific site, log all (search bots) user agents for a while.
    1 point
  35. See here for how you can add those settings via hooks:
    1 point
  36. @szabesz and @godmok Ok, new version supports custom labels and input widths on a per field basis. The subfield labels are now also translatable: So in this example, the Spanish rendering looks like this: Please let me know if you have any issues/suggestions. Note for @mel47 - there is currently an issue with the multi-language subfield labels in FormBuilder. Waiting on Ryan here: https://processwire.com/talk/topic/18347-subfield-uselanguages-not-getting-re-populated/
    1 point
  37. Not sure about SQL schemas, but you should take a look at these options: https://github.com/adrianbj/ProcessMigrator/blob/master/README.md https://processwire.com/blog/posts/processwire-3.0.68-and-more-on-page-export-import/ Importing and exporting fields and templates has been in core for a while now. The format which is used is JSON. You could just as well write JSON yourself for automatic creation. The import feature is labelled "beta" though - perhaps test it out on a dev system first and see how it goes.
    1 point
  38. Indeed. I run a medium website in a VPS with 2GB and hardly use more than 70% of the RAM.
    1 point
  39. If anybody wants to give it a try, here's a little attempt at an OR-group capable PageArray extension (just to see if this might be worth investing some more time and creating a PR). Usage: $regularPageArray = $pages->find("template=mytemplate"); // Returns an OrGroupsPageArray instance with the contents of $regularPageArray: $groupable = $regularPageArray->getGroupable(); $groupable->filter("fieldA=1, (fieldB=today), (fieldB=tomorrow)"); // or $filtered = $groupable->find("fieldA=1, (fieldB=today), (fieldB=tomorrow)"); OrGroupsPageArray.zip
    1 point
  40. Nice module, thanks for sharing. I wonder though how effective it really is reading the last two sections "caveat emptor" and "blackhole whitelist": https://perishablepress.com/blackhole-bad-bots/#blackhole-whitelist
    1 point
  41. I think there should be an annual award for best module.
    1 point
  42. Yeah totally! I saw that suggested by @adrian in the other MySQL thread. It's gonna be very interesting to see what my $pages->find() are actually doing.
    1 point
  43. http://www.karenthomasphotography.com/ modules: AIOM+, ProcessPageDelete, TextformatterVideoEmbed. js: isotope, imagesloaded, fitvids, scrollTo, and Jquery with custom AJAX magic.
    1 point
  44. Love the image actions feature, thanks! Especially looking forward to this one... ...as I had a need for this recently. I don't intend to give users access to the "special effect" options (B&W and sepia) for the same reason I wouldn't give users the ability to change fonts or text colours - there's always some editor who considers themselves an "artist" and will take a carefully designed site and turn it into a dogs breakfast. In case anyone else feels the same, it's simple to remove these with a hook in /site/ready.php: $wire->addHookAfter('InputfieldImage::getFileActions', function(HookEvent $event) { $actions = $event->return; unset($actions['bw']); unset($actions['sep']); $event->return = $actions; });
    1 point
  45. Radio Hala96 FM is a radio service that aims to promote the community through presenting a program map with creativity and thought for all groups. On March 15, 2014, Hala began a live broadcast with a unique programming program that brings you daily on a useful and exciting weekend trip. The Website Is Developed By I&S Group & Powered By The Great ProcessWire & It's Awesomeness That We All Love. .
    1 point
  46. This week we have a guest post from Bernhard Baumrock that is a nice introduction to creating Process modules in ProcessWire. Bernhard covers a lot of useful material here and we hope you enjoy it. Big thanks to him for his contribution this week. I've been traveling (Ryan) for the last two weeks, but arrived back in town last night, so next week we'll be back to our regular PW core updates and schedule. https://processwire.com/blog/posts/building-custom-admin-pages-with-process-modules/
    1 point
  47. Based on this forum post, I wanted to find a more elegant solution for changing a field's settings per template. Hooking the page editor after it generates the form works and may still be needed for more complex modifications. But using field & template context, it's easier to modify the field settings and it greatly reduces the need for creating an almost identical field just to adjust a few things. In my blog post, I've written on how to extend contextual options to allow any fieldtype / inputfield settings to be changed depending on the template. Hope you find it useful, and if you have any questions or comments, feel free to post them here. https://abdus.co/blog/doing-more-with-fewer-fields-in-processwire/
    1 point
  48. Personal preference, I should think, but he also gave us (well, those of us skilled enough to take advantage) the tools to change that behaviour.
    1 point
  49. For a little more info on what I found which will hopefully help others: There were lots of JS errors in the browser developer tools Console tab like this: Uncaught SyntaxError: Unexpected token < which is a good indication that there is an error message, or at least some HTML being returned in the AJAX request which is not expected by the JS script. So then I went to the Network tab of the developer tools and found the script that is uploading images (?id=1&InputfieldFileAjax=1), and checked the response - that is where I found this login form: Also. of course, when I saved the page, it asked me to login again, so that was also a hint. @Roberts R mentioned that he didn't get the console errors - turns out he didn't have "Disable Cache" checked on the Network tab and apparently that made a difference. I always have it checked because Chrome caching drives me crazy but this might be a helpful hint for others.
    1 point
  50. But where I have to put this code? inside of the html page? By the way, im not using ryan's MapMarker module
    1 point
×
×
  • Create New...