Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/19/2019 in all areas

  1. At the moment these are strict requirements. To be honest, I wasn't aware of the fact that JSON data type in MySQL requires InnoDB. The module, as it is now, will not work on MySQL < 5.7.8 I added that info to the module requirements. Almost all of the sites that I am working on run on MySQL >= 5.7.8. InnoDB. But I understand that not every site can fulfill these requirements. After reading your comments here about this possibly being an issue for some people, I am thinking about redesigning the storage part. ATM I already have separate columns for storing pageid and filename plus that extra JSON column. Will contemplate some more and see if I can come up with a good solution. Maybe only using json if the hosting environment supports this. I'll see.
    3 points
  2. Now that the major update for my ImagePicker module is out, I wanted to share how I managed to make images from a folder in site/templates/ behave like a Pageimage with full resizing/cropping capabilities. This was probably the biggest challenge in developing the new features. I first thought to create a hidden page in the page tree that will hold all these images. But this would not have been a clean solution. So I took a closer look on how the Pageimage and Pageimages objects are constructed. Finally I decided to use a virtual (or fake) page to hold the images. It required some method overriding of the Page class and the PagefilesManager class to adjust the paths. Normally images for a page can only live in a folder in site/assets/files/pageid. By manipulating the path of Pagefilesmanager I was able to create a custom ImagePickerVirtualpage object and assign the images from the folder to that page. The virtual page is created at runtime and the DB never sees it. It took quite some trial and error to accomplish this. But finally, you can now manipulate these images just like any other Pageimage object (resizing/cropping). The resulting image variations will be stored in the same folder. There is one little stumbling block. I use an existing images field from the site my field is installed on and assign it to a virtual template of my virtual page. This field then holds all the folder images. I figured that every site that will use my module will already have an images field installed. Very rarely this will not be the case. So for the time being I am leaving the logic as it is. If I find people running into problems, I will adjust this. Code can be found here. One more thing that offered some challenge was storing the data as JSON in the DB and have it fully searchable through the API. Luckily I found an old (and abandoned?) module JsonNativeField from @BitPoet that does just that: store values as JSON and make them searchable. So I borrowed the DB schema and most of the getMatchQuery logic from that module. I still have 2 extra columns for pageid and filename in the DB table. These make sure that in the Pagefinder you can use subfields. Kind of redundant info in these columns but I couldn't figure out another way of making the subfield search work in Pagefinder. If you happen to know how to accomplish this, please enlighten me. Main advantage of JSON storage is that my image field can be used with the marcrura's SettingsFactory module. Also storing values of multiple images this way will be easy and will come in handy once I extend my module to support multiple images.
    2 points
  3. Maybe take a look here: https://github.com/processwire/processwire-issues/issues/1041 https://github.com/processwire/processwire-issues/issues/943 You may need to either install a lower version of PHP, or upgrade to the dev branch latest.
    2 points
  4. @gebeer - no time to see what you've done vs what I have done in the past, but I just wanted to quickly link to: in case it's at all useful. Maybe your approach is the same or better?
    2 points
  5. Guys, just to give you an update: I still want and have to work on this module before I can release it on github. I am changing a big part of the rendering of the actions, so they work either in card or in table view. Sadly I hadn't much time in the past, because I changed my company to a GmbH, had to design a new logo and website texts, and all that legal stuff that comes with changing your company. And don't forget about my customers, who also want their work done. I hope to get some time in the next weeks, so maybe I can work after christmas on this, but no promises.
    2 points
  6. I don't really have anything public to show, as nearly all the work is back-end, but I thought I'd post here anyway as it's a pretty good example of just how powerful Processwire can be. About a year ago, I inherited an incomplete Craft website made by a designer. Apart from the usual company information site, it was supposed to provide a customer portal for clients of a wine bottling company to make bookings for production runs. Data for stock levels of goods like bottles and labels was to come from an inventory management system Unleashed https://www.unleashedsoftware.com/ Unleashed provides a REST API, so I had to integrate with that first by writing an API integration module, and then ended up using Processwire's core lazy cron module to periodically pull data from Unleashed using a custom module. The booking forms have a lot of conditional fields, eg if you are bottling a given wine variety, you should only be able to select labels that match that variety. All this conditional stuff was achieved with a lot of additions to ready.php. I also needed to be able to created a predefined set of pages when a new user is added if they have a 'client' role. Once again, more hooking in ready.php I've used the Admin Restrict Branch module so clients can only see their own records when they're logged in, but staff can see all records. Lister Pro provides the ability to search and view completed production runs. Part way through the project, as the client was happy with the way things were going, I was asked to add in logistics and dispatch which is provided by another company, which also runs Unleashed with a separate set of data, and with some clients who don't bottle wine, but will end up using the same portal, so using the roles and permissions inherent in Processwire, I set up production templates with separate roles to dispatch templates, so I could easily have clients assigned access to just the templates they need. Tracey Debugger got a thorough workout along the way, and the debugger console is an absolute killer tool for making quick changes to data when updating a live site to match changes from the dev site. At the start of this project, I'd used Processwire quite a bit, but never dived into module development or hooking, but I've now ended up with a reasonable idea how they work. @bernhard has produced some excellent tutorials which I found really helpful figuring out how to create modules, and other people like @Robin S have answered questions when I've got stuck. @ryan himself has been helpful when I've been trying to do things that push either the limits of my knowledge or Processwire or both ? . Could I have done this with other tools? Depends. Wordpress would have been as useless as using petrol to fight a fire, however something like ASP.Net COULD have done the job but would have probably made things a lot more complicated. In parallel, I've been working on building a REST API with ASP.Net for another client to integrate with an existing SQL Server database, and I've found that Visual Studio is inclined to break projects quite regularly, with dependencies getting messed up, or even whole configuration files getting corrupted when it has a hissy fit, so working with Processwire is a pleasure in comparison.
    2 points
  7. Hello all, sharing my new module FieldtypeImageReference. It provides a configurable input field for choosing any type of image from selectable sources. Sources can be: a predefined folder in site/templates/ and/or a page (and optionally its children) and/or the page being edited and/or any page on the site CAUTION: this module is under development and not quite yet in a production-ready state. So please test it carefully. UPDATE: the new version v2.0.0 introduces a breaking change due to renaming the module. If you have an older version already installed, you need to uninstall it and install the latest master version. Module and full description can be found on github https://github.com/gebeer/FieldtypeImageReference Install from URL: https://github.com/gebeer/FieldtypeImageReference/archive/master.zip Read on for features and use cases. Features Images can be loaded from a folder inside site/templates/ or site/assets Images in that folder can be uploaded and deleted from within the inputfield Images can be loaded from other pages defined in the field settings Images can be organized into categories. Child pages of the main 'image source page' serve as categories mages can be loaded from any page on the site From the API side, images can be manipulated like native ProcessWire images (resizing, cropping etc.), even the images from a folder Image thumbnails are loaded into inputfield by ajax on demand Source images on other pages can be edited from within this field. Markup of SVG images can be rendered inline with `echo $image->svgcontent` Image names are fully searchable through the API $pages->find('fieldname.filename=xyz.png'); $pages->find('fieldname.filename%=xy.png'); Accidental image deletion is prevented. When you want to delete an image from one of the pages that hold your site-wide images, the module searches all pages that use that image. If any page contains a reference to the image you are trying to delete, deletion will be prevented. You will get an error message with links to help you edit those pages and remove references there before you can finally delete the image. This field type can be used with marcrura's Settings Factory module to store images on settings pages, which was not possible with other image field types When to use ? If you want to let editors choose an image from a set of images that is being used site-wide. Ideal for images that are being re-used across the site (e.g. icons, but not limited to that). Other than the native ProcessWire images field, the images here are not stored per page. Only references to images that live on other pages or inside a folder are stored. This has several advantages: one central place to organize images when images change, you only have to update them in one place. All references will be updated, too. (Provided the name of the image that has changed stays the same) Installation and setup instructions can be found on github. Here's how the input field looks like in the page editor: If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Install from URL: https://github.com/gebeer/FieldtypeImageReference/archive/master.zip Eventually this will go in the module directory, too. But it needs some more testing before I submit it. So I'd really appreciate your assistance. Thanks to all who contributed their feedback and suggestions which made this module what it is now.
    1 point
  8. https://dockyard.com/blog/2019/12/19/lessons-learned-10-years-of-running-a-software-consultancy
    1 point
  9. Metadata Exif Version 0.9.0 (currently a WIP) for PW 2.8.+ / 3.0+ This is a new attempt to add easy EXIF reading support to ProcessWire. It should be an easy and less error prone API task. Thats why the module internally uses lowercase key names for all EXIF keys and all of your requested key names. But you are not forced to use lowercase key names, you can use any mixed chars for it as you like. You will get back an array or object with keynames / properties named the same (casesensitive) way as you have passed them in with your request. API The module adds one hook to the Pageimage: getExif($options = null) Without any $options passed to the method, it returns all EXIF data in a RAW multidim array. Passing a simple list with requested key names as array to it returns an array with only the values of those requested keynames. If you want change the output from array to object, you can use the a boolean "toObject" set to true. Additionally to this and / or any other option, you need to put your requested keynames list to the option "keys". $rawArray = $image->getExif(); $options = array('Whitebalance', 'Flash', 'ISOSpeedRatings', 'FNumber', 'UserComment'); $array = $image->getExif($options); $options = array('toObject' => true, 'keys' => array('whitebalance', 'flash', 'isospeedratings', 'fnumber', 'usercomment')); $object = $image->getExif($options); Possible options are A working example $options = array( 'keys' => array('ISOSpeedRatings', 'FNumber', 'Flash') ); echo "<table><tr>"; foreach($options['keys'] as $key) echo "<th>{$key}</th>"; echo "</tr>"; foreach($page->images as $image) { $exif = $image->getExif($options); echo "<tr>"; foreach($exif as $value) echo "<td>$value</td>"; echo "</tr>"; } echo "</table>"; This will output something like: With the boolean option "unformatted" passed as true, the output would look like: For some keys, that only store something like integer values, what are not very meaningful to most of us, the module contain xyzFormatted methods. This way, it is easy to enhance and maintain the module in the future. Help wanted It would be nice if some of you test the module and report back if the intended API suites your needs. And you are very welcome to post suggestions for which keys you want to have a ...Formatted method. Thank you! https://github.com/horst-n/MetadataExif
    1 point
  10. @Gadgetto You may ask the maintainer(s) of the (german) language pack to include it.
    1 point
  11. Not as far as I know. (only with site-profiles, but that's a completely different scenario) I guess one reason is that you probably don't want to install another language, just because a module author has a pre-defined set of languages that don't match with your own site setup. Though I assume if you would create new templates with your module, and use the __() syntax, PW will automatically create the necessary JSON translation files. Or at least, PW will list them in the language menu (where you can select templates that don't yet have a ML JSON file, and then you can create new json files and fill in the strings on the following step). <offtopic> multi-language handling in any system is complex. The more you have to deal with it, and dig deeper into the subject, the harder it gets. </offtopic>
    1 point
  12. Hey there Jim, welcome to the forum! I've seen a few other reports related to the developer directory pop up lately as well. @Pete, you aware of these? ?
    1 point
  13. I'd look into unicode's cldr database and something like e.g. https://punic.github.io/
    1 point
  14. A former experienced colleague of mine put it right (regarding Bootstrap, but applicable here as well): If you don't know coding, it's a bless, if you do, it's a curse ?
    1 point
  15. Thanks for that link. I first was taking a similar approach, passing a fake page to construct the Pageimages object. But every time I added an image from the folder to the Pageimages instance with $pageimages->add($pathtofile) it would add this file to the folder again. So with every add() call I created redundant extra files. BUT I didn't pass a Field instance like you did. So will give this a try.
    1 point
  16. Well I thank you very much for taking the time out to look into it for me. That was some quick turn around time!
    1 point
  17. All my fault - it actually was an issue with those checks on the line you pointed out. The difference on my test site was that even though I didn't have the tracy-home-dev permission checked, it was created so the conditional was returning true. On your site that permission didn't exist so it wasn't proceeding. The first check now also checks for the "all" version of that permission before checking if the current user has it.
    1 point
  18. Thanks @alexmercenary - I found the issue and it should be all fixed now. I have updated your site to the new version of Tracy that includes the fix. Let me know if you have any other problems.
    1 point
  19. It looks like it's nested inside another if condition so doesn't ever get checked perhaps in TracyDebugger.module.php on line 1306? EDIT: Ignore that. Misread. It's late here, sorry! Haha.
    1 point
  20. I was expecting it to work for all templates.
    1 point
  21. Hi all, Is anyone else noticing that using permission tracy-all-dev doesn't work? tracy-home-dev works fine however. Am I being silly and overlooking or misinterpreting something?
    1 point
  22. Gadgetto thanks for your solution! ? Guys, I found what I was looking for: https://processwire.com/talk/topic/9007-utility-to-help-generate-module-install-function/ it just uses normal processwire json export strings for fields and templates and seems for me to be the simpliest solution... I used it once somewhere in a module, it worked, but I forget where I had it.. ?
    1 point
  23. @gebeer, I have similar concerns as @szabesz, not just about the InnoDB requirement but the MySQL >= 5.7.8 also. I think a lot of hosts and existing sites out there are not going to meet that requirement. For instance all my sites use MariaDB and as far as I know there isn't full JSON support in MariaDB yet. Could you please clarify if InnoDB / MySQL >= 5.7.8 are strict requirements for the module? And if the module will partially work with MyISAM / MariaDB / MySQL < 5.7.8 which features would not be available?
    1 point
  24. Thanks Teppo! If I decide to take on the proposed multi-lingual project in 2020, I will revisit this. I just wanted to have a fair number of options to choose from. Perhaps over the holidays I will try again but see if choosing a single language site has any performance issues in my environment. If not, I will report back for sure. Dave
    1 point
  25. With the help of @Noboru I could fix some bugs in the "Extended Resources" installer and with float values in prices. Some rare problems could be fixed and the installer is more stable now. A big problem is the integrated taxes-provider regarding shipping-.taxes. I'm in contact with the Snipcart team to make this as flexible as possible. This isn't easy as we have very different taxes system around the countries of the world.
    1 point
  26. Oh, I just see, that you need an account to get geonames. No public API. So this isn't suitable for my SnipWire plugin. Edit: And I just found the limits: 20'000 credits daily limit per application (identified by the parameter 'username'), the hourly limit is 1000 credits. A credit is a web service request hit for most services. An exception is thrown when the limit is exceeded.
    1 point
  27. Processwire version: 3.0.123 © 2019 - which site profile did you use on installation? I used a blank profile - where did you try to add a new page in the page tree (Home or other page)? I tried hope and other pages all of them say the same its a fairly small webpage. - which templates did you create apart from home and basic-page? I'm doing a one pager where i use diffrent templates to do diffrent stuff in the flow. So I have Home , Onecolum, twocolum. and that's it.? Maybe it will be easier to re install. - did you change the 'Family' settings of any of the templates? I don't think so only home said you can't use templates on other pages. Otherwise look at photo ? Thanks for helping
    1 point
  28. A bit off-topic, but while typecasting an empty array to boolean does indeed result in false, "empty($array)" has its benefits. It's slightly more verbose, but it also won't cause a notice if $array hasn't been defined yet, and it's arguably more obvious (leading to better readability). Relying on typecasting can sometimes result in obscure issues, as well as make the code ever so slightly harder to decipher. Using "count" to check if an array is empty is a common mistake. Even if in most cases the actual performance difference is too small to really matter, there's no reason to do this ??
    1 point
  29. There's a point though. Perhaps a ISO language code dropdown could be added to the language template together with a checkbox to allow automatic installation of language packs by new modules according to the selected value. This would keep backwards compatiblity yet allow for automatic installation (through module install). Adding a mechanism to query installed modules whether they provide translation packages for newly added languages could be accomplished by hooking Languages::added. The only problem I see are languages that differ quite a bit in ISO 639-1 groups, which, for example, captures all variants of Chinese under the lable zh. Yet ISO 639-3 may be too fine-grained. A two-part solution like Unix and Windows use would IMHO be better (e.g. zh-cn, de-de, with fallback to the first two letters).
    1 point
  30. You're mentioning exactly the point, which does prevent that. It would need some kind of standard about language naming and that one is simply not existing in processwire (and even might not in the future). Languages (besides default) can be named however the admin does feel like. You could always implement a custom function into the install() method to check for languages named correctly and if so install any files. Other people would need to install them manually. Also a point about the default language. This one can be any language, but it's always named default. That's a problem as well.
    1 point
  31. That's my article, using Ajax is quite easy in PW, just make an Ajax call to your page, now the HTTP Header contains Ajax header in it, so $config->ajax will flag as true when it is an Ajax call and false if not, Do this 1. Make an Ajax Call to the Page 2. var_dump something if Ajax and exit and you will see your result 100% cleaner than WordPress and i stick to that statement, also thanks for reading my blog. If you have something you want me to write on please let me know, quite bored at home.
    1 point
  32. Yes, the export generates JSON. It's all documented here: https://processwire.com/blog/posts/august-2014-core-updates-1/ - Field export/import And here: https://processwire.com/blog/posts/august-2014-core-updates-3/#template-export-import - Template export/import and more here: https://processwire.com/talk/topic/2117-continuous-integration-of-field-and-template-changes/?p=68899
    1 point
×
×
  • Create New...