Jump to content

gebeer

Members
  • Content Count

    996
  • Joined

  • Last visited

  • Days Won

    23

Everything posted by gebeer

  1. @kongondo all is good! That ___getSelectorInfo() method was exactly what I needed. It is already live on github
  2. Big thanks for this one. I'll give it a shot. This I already covered. Got it from the Map Marker example module 🙂 EDIT: New v1.1.2 went out just before I read this. Will update soon.
  3. I just released v1.1.2 which has all the same features but removes dependency from MySQL >= 5.7.8 and fixes some minor issues. The module can now be used on any MySQL setup. You can update to or install from scratch the latest master version. If you run into problems, please report here or open an issue on github. Thank you.
  4. Testing right now and it is working. One thing boggles me. In Pagefinder, when selecting Subfield, I cannot select filename as subfield, only pageid. I had this with another custom fieldtype and always wondered how to have the alias for data show up here.
  5. I had kicked data alltogether until I realized that a search for none empty returnes SQL error. Now I added it back in and will use it for the filename. Then everything should work, I guess...
  6. @kongondo is the data column mandatory? I get strange results for searches.
  7. Thank you for the info. That is exactly what I am going to do now. Up to the point where I started developing this module, I was not really familiar with how field values travel through a live cycle. But meanwhile I realized, that the return value of wakeupValue() is what gets passed to the inputfield. I am returning json here already. And now that I decided to kick the JSON data column altogether, the redundancy will be gone 🙂
  8. Problem is, that you cannot predict which names people use for languages. So you cannot rely on a specific standard here. If someone installs your module who has named the German language 'german' and not 'de_DE', the module author has no way to reliably map translation files to country names.
  9. Once you want to translate your module, go to Setup->Languages->yourlanguage, choose to translate your module files, do the translation in the interface and then download the resulting json. That should be it.
  10. As far as I understand it, you could bundle language translation json files with the module, let's say in a module folder 'translations'. They won't be installed automagically, though. But in the language edit interface, you can add these json files manually to the 'Site Translation files'. Or am I wrong here?
  11. Just wanted to follow up on this. In the current master (v1.1.1) I changed the logic loosely following adrian's approach. This is working fine now. Also it removed an issue that occured with my previous approach. I still need the virtual page, though, to instantiate the Pageimages object. But now my virtual page doesn't need a real images field anymore 😀. It is working with a virtual Field now. Code is here.
  12. May I ask for the reason behind this? Ryan mentions some advantages of InnoDB over MyIsam in this blogpost. The good news for you: next version (v1.1.2) of the module will revert back to not using MySQL native JSON data type so it will be compatible MyIsam.
  13. Yes, I have a 'double storage' at the moment. Because I had not finally decided how to handle this. So atm there is redundant data. Main reason for adding that JSON column was so I can support SettingsFactory which only can store text values. Also, after switching to JSON storage, I left pageid and filename columns so that in the Pagefinder you can choose these as subfields. Do you know a better way to handle this? Anyways, I will be going to set data column as a text in the next version to avoid the MySQL >= 5.7.8 requirement and amend the query logic to query pageid and filename columns instead of doing the JSON_SEARCH() on the data column.
  14. Sorry, that was the only thing I figured could be wrong. Maybe someone else can jump in?
  15. Just noticed, that the $field->setImportData($fieldData) method is not documented at https://processwire.com/api/ref/field/
  16. 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.
  17. 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.
  18. 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.
  19. Yes, they do. You can pass a lang parameter to your query to get results in a specific language. Just tested this with Russian http://api.geonames.org/countryInfoJSON?formatted=true&lang=ru&username=gebeer&style=full Information on the webservices they offer: http://www.geonames.org/export/web-services.html Documentation is a bit sparse...
  20. Seems it is still maintained and pretty up to date: https://www.geonames.org/recent-changes.html
  21. It is done. I have merged this module with the ImagePicker module. Now it includes almost all requested features. It is published as FieldtypeImagepicker on github. I will update the ImagePicker thread shortly and continue discussion there. Hope to see you!
  22. Thing about country info is that it changes all the time. I find https://www.geonames.org/export/ws-overview.html a good resource for getting up-to-date country information. They have a JSON and an XML API. And the country info also available as CSV. You can query for all countries JSON with http://api.geonames.org/countryInfoJSON?formatted=true&username=gebeer&style=full (note my username. You'd have to create your own) I used this on a custom address field type that pulls in location data in real time while filling in an address https://github.com/gebeer/FieldtypeAddressGeonames Developed it for a course directory site where 1000+ users login from all over the world, to make sure the address info is as uniform as possible.
  23. I think you need to return the modified argument $forms->addHook('FormBuilderProcessor::renderReady', function($e) { $form = $e->arguments(0); if($form->name != 'enquiry_form') return; $inputfield = $form->getChildByName('cart'); if($inputfield) { $cart = json_encode(wire('session')->get('cart')); $inputfield->attr('value', $cart); // you can try var_dump($inputfield->attr('value') here to see if the value was set } $e->arguments(0, $form); // this will return the modified form object to the hooked method });
  24. Please provide some more information: - ProcessWire version - which site profile did you use on installation? - where did you try to add a new page in the page tree (Home or other page)? - which templates did you create apart from home and basic-page? - did you change the 'Family' settings of any of the templates? It is hard for us to guess all these things. This information will help us to help you.
  25. Thank you for testing! This is intended behaviour at the moment. But I am planning on incorporating an upload widget for the folder images, too. For uploading the page images the module uses the standard PW page edit feature. But since folder images are not linked to a page (at least not yet in the current version), I need to use a different solution here. I like https://uppy.io/ a lot and think I will implement it for managing images in the folder. I have merged all the features of this module into my ImagePicker module and will release a new version of that this week.
×
×
  • Create New...