Jump to content

Robin S

Members
  • Content Count

    3,672
  • Joined

  • Last visited

  • Days Won

    212

Everything posted by Robin S

  1. @matjazp, that's strange. The link is to the Single version of ProMailer, which I can see in the store: Maybe that option is only visible to purchasers of ProDevTools, because when ProMailer launched Ryan said that he would provide a Single version of ProMailer to ProDevTools users on request (perhaps he sends a coupon code?) But it might instead be an access glitch so I suggest that anyone interested in purchasing the single version contact Ryan to ask about it.
  2. This was due to $config->fileContentTypes not having up-to-date MIME types. I created an issue here and decided it would be better to make the MIME type > file extension mapping configurable in v0.2.2 rather than using $config->fileContentTypes. Please update the module and the problem should be fixed. P.S. This page is a useful resource if anyone wants to set additional MIME type mappings: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types
  3. Here's some updated code to try: // Find IDs of users that have been active in the last $mins number of minutes function onlineUserIDs($mins, $limit = 500) { $table = SessionHandlerDB::dbTableName; $seconds = $mins * 60; $sql = "SELECT user_id " . "FROM `$table` " . "WHERE ts > DATE_SUB(NOW(), INTERVAL $seconds SECOND) " . "AND user_id!=40 " . // exclude guest "ORDER BY ts DESC LIMIT $limit"; $query = wire('database')->prepare($sql); $query->execute(); $results = $query->fetchAll(\PDO::FETCH_COLUMN); return $results; } // User IDs active in the last hour $online_user_ids = onlineUserIDs(60); // Convert to string for use in selector $online_user_ids = implode('|', $online_user_ids); // Online users $online_users = $users->find("id=$online_user_ids"); // Offline users excluding guest user $offline_users = $users->find("id!=$online_user_ids, roles.count>1");
  4. No, but you can use a "fake" PageArray to paginate other things, as described by Ryan here:
  5. Sort of. This does the job but is somewhat hacky: $wire->addHookBefore('InputfieldRepeater::render', function(HookEvent $event) { $inputfield = $event->object; $session = $event->wire('session'); // Existing open IDs from core (e.g. items that contain errors) $existing_open_ids = $session->getFor('InputfieldRepeater', 'openIDs') ?: []; // Find the IDs of items you want to render in open state $open_ids = $inputfield->value->find("images.count>1")->explode('id'); // Merge IDs $open_ids = array_unique(array_merge($existing_open_ids, $open_ids)); // Set open IDs to session $session->setFor('InputfieldRepeater', 'openIDs', $open_ids); }); $wire->addHookBefore('InputfieldRepeater::processInput', function(HookEvent $event) { // Clear open IDs from session $event->wire('session')->removeFor('InputfieldRepeater', 'openIDs'); }); Would be nice to have a proper API method to do this.
  6. If you only need the count of $progretti then you can use the more efficient $pages->count() method. And you might find the Connect Page Fields module useful to create two-way connections between the pages in your Page Reference fields. This can help avoid the need for additional PageFinder queries inside the foreach because the projects for each supplier can be stored in a Page Reference field in the supplier template. Also, please use code blocks when posting code in the forum to make it more readable.
  7. v0.2.0 released, which makes the stubs directory path configurable and includes a checkbox in the module config to manually regenerate all stub files if needed (thanks @teppo).
  8. That's a better location for the stub files - I've switched to that in v0.1.8.
  9. I've added support for these sorts of remote files in v0.2.1.
  10. I don't have any fixes for this module, but I created a similar module that I have now released:
  11. This module is inspired by and similar to the Template Stubs module. The author of that module has not been active in the PW community for several years now and parts of the code for that module didn't make sense to me, so I decided to create my own module. Auto Template Stubs has only been tested with PhpStorm because that is the IDE that I use. Auto Template Stubs Automatically creates stub files for templates when fields or fieldgroups are saved. Stub files are useful if you are using an IDE (e.g. PhpStorm) that provides code assistance - the stub files let the IDE know what fields exist in each template and what data type each field returns. Depending on your IDE's features you get benefits such as code completion for field names as you type, type inference, inspection, documentation, etc. Installation Install the Auto Template Stubs module. Configuration You can change the class name prefix setting in the module config if you like. It's good to use a class name prefix because it reduces the chance that the class name will clash with an existing class name. The directory path used to store the stub files is configurable. There is a checkbox to manually trigger the regeneration of all stub files if needed. Usage Add a line near the top of each of your template files to tell your IDE what stub class name to associate with the $page variable within the template file. For example, with the default class name prefix you would add the following line at the top of the home.php template file: /** @var tpl_home $page */ Now enjoy code completion, etc, in your IDE. Adding data types for non-core Fieldtype modules The module includes the data types returned by all the core Fieldtype modules. If you want to add data types returned by one or more non-core Fieldtype modules then you can hook the AutoTemplateStubs::getReturnTypes() method. For example, in /site/ready.php: // Add data types for some non-core Fieldtype modules $wire->addHookAfter('AutoTemplateStubs::getReturnTypes', function(HookEvent $event) { $extra_types = [ 'FieldtypeDecimal' => 'string', 'FieldtypeLeafletMapMarker' => 'LeafletMapMarker', 'FieldtypeRepeaterMatrix' => 'RepeaterMatrixPageArray', 'FieldtypeTable' => 'TableRows', ]; $event->return = $event->return + $extra_types; }); Credits Inspired by and much credit to the Template Stubs module by mindplay.dk. https://github.com/Toutouwai/AutoTemplateStubs https://modules.processwire.com/modules/auto-template-stubs/
  12. You could change your Select Options fields to Page Reference fields. Page Reference fields are more powerful and flexible and the better choice in most cases. One of the advantages is that users can edit, sort, add and remove options for fields simply by working with the pages that represent the options. You can create a References branch in your page tree to hold the option pages for your Page Reference fields, and the Page Field Select Creator module is useful for quickly setting up new fields.
  13. v0.1.6 released. Adds module config options to override the requirements coming from the password inputfield, so the generator can create stronger passwords than the inputfield requires.
  14. v0.2.0 released, which adds support for File fields so that file URLs can be added the same as with Image fields. Thanks to @gmclelland for the idea. I've also submitted the module to the directory now seeing as it seems to be working well without any significant issues reported.
  15. Hi @ryan, I see that when FileValidatorImage is installed it is automatically employed by all InputfieldImage and InputfieldFile inputfields. I assume this means that there is no downside to having this validation so there is no need to allow the user to choose which fields it applies to (e.g. only specific inputfields used on the front-end by non-trusted users). But if it's all upside and no downside then wouldn't it be better to have this module installed by default in the PW core and not as a separate non-core module?
  16. Prefix the name with \ to specify the global space: $foo = new \SimpleXMLElement($data);
  17. It's not documented but you can use two curly braces to achieve de-emphasised text:
  18. That's not the same thing. They are basically the opposite of each other. The hook method above allows for a specified number of items in each sub-WireArray, with the number of resulting WireArrays not specified. WireArray::slices() allows for a specified number of sub-WireArrays, with the number of items in each sub-WireArray not specified. To illustrate:
  19. I think the getExif() method should throw an exception if the module requirements aren't met. But the module could also check for this when it's installed. Unfortunately I don't think it's possible to include PHP extensions in the "requires" item of getModuleInfo() but the Module documentation says (after correcting typo): So the install method could be this: public function ___install() { if(!function_exists('exif_read_data')) { throw new WireException('MetadataExif requires the PHP exif extension.'); }; }
  20. Hi @horst, Thanks for this module! It would be great if the module alerted the user somehow if the required PHP exif extension is not installed. I spent some time trying to work out why I couldn't get any data back from images and it wasn't until I saw this in the module code... if(!function_exists('exif_read_data')) return null; ...that I realised my local WAMP stack didn't have the exif extension enabled.
  21. Yes, in this example I was saving in the admin. Thanks.
  22. Hi @adrian, I'm having another problem with pages not being renamed when "Enable for API" checked. As a demo, here are my module config settings: {"PageRenameOptions":{"version":"1.0.5","settings":{"enableForApi":1,"renameMatchTitle":1,"renameWithoutTitleChange":"","renameUnpublishedOnly":"","includeExclude":"exclude","exemptTemplates":[],"exemptPages":[],"exemptRoles":["superuser"],"initialDifference":1,"preventManualChanges":1,"liveChanges":null,"uninstall":"","submit_save_module":"Submit"}}} In ready.php I have this hook: $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'basic-page') { $page->title = uniqid(); } }); For any page using the basic-page template, the page gets a new title on every save as expected but the name is not updated. I tried turning off "Initial differences protected" in case that was related, but pages are not renamed then either.
  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?
×
×
  • Create New...