Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/06/2019 in all areas

  1. This week we’ll take a look at a new version of FormBuilder that's on the way (with a screencast), as well as the latest version of the core: ProcessWire 3.0.140— https://processwire.com/blog/posts/pw-3.0.140-and-formbuilder-v40/
    17 points
  2. This module gets people confused ?. Yes, it is both. Page Table is a pro module based on a concept by @apeisa, coded by @ryan and sponsored by Avoine where Antti works. Avoine offered the module to the ProcessWire community for free (through their sponsorship). Edit: For some reason, the above link is not linking correctly to the single post where Ryan explains the difference between the modules. Here is the direct link. It is Ryan's 3rd post on page 2 of that thread. TLDR; Table and Page Table are different modules. Both are pro fields. The latter is available to us for free, thanks to Avoine. ?
    7 points
  3. This doesn't warrant a full tutorial, but I wrote a little function that will recursively search through a repeater field to find the first non-empty field matching a list of fields to look for. I needed something like this to generate a fallback for SEO fields (og:image, og:description et c.). Here it is: <?php namespace ProcessWire; /** * Find the first non-empty field out of a list of fields in a repeater or repeater matrix field. * Will recursively search through nested repeaters until it finds a non-empty * field. * * @param RepeaterPageArray $repeater The field to search through. * @param array $fields A list of fields the function should look for. * @param array|null $allowed_repeater_types All the Repeater Matrix types the function will check. Leave empty to allow all. * @param array|null $allowed_repeater_fields All the repeater fields the function will check recursively. Leave empty to allow all. * @return void */ function firstRecursiveRepeaterMatch( RepeaterPageArray $repeater, array $fields, ?array $allowed_repeater_types = null, ?array $allowed_repeater_fields = null ) { // iterate over the items of the repeater foreach ($repeater as $current) { // if the function is currently inside a repeater matrix field, // skip this item if it isn't one of the allowed types, unless // allowed_repeater_types is empty (all types allowed) if ( $current instanceof RepeaterMatrixPage && is_array($allowed_repeater_types) && !in_array($current->type, $allowed_repeater_types) ) { continue; } // get all fields of the current item foreach ($current->getFields() as $field) { $name = $field->name; // if the current field is another repeater, check it recursively $fieldtype_class = $field->getFieldType()->className(); if ($fieldtype_class === 'FieldtypeRepeater' || $fieldtype_class === 'FieldtypeRepeaterMatrix') { // continue with the next item if the field name isn't one of the // allowed repeater fields, unless allowed_repeater_fields empty (null) if ( is_array($allowed_repeater_fields) && !in_array($name, $allowed_repeater_fields) ) { continue; } $deep_search = firstRecursiveRepeaterMatch( $current->get($name), $fields, $allowed_repeater_types, $allowed_repeater_fields ); // if the deep search inside the repeater // finds something, the function ends here if ($deep_search !== null) { return $deep_search; } } // if the current field name is one of the requested // fields, return it's value if it isn't empty if (in_array($name, $fields)) { $value = $current->get($name); if ( // check for empty values !empty($value) // if the value is any wirearray, check // if it has at least one item && (!$value instanceof WireArray || $value->count() > 0) ) { return $value; } } } } // if the function reaches this point, there is no match in the entire tree return null; } Can be used like this: $seo_description = firstRecursiveRepeaterMatch( // content sections fields, a repeater matrix with multiple types $page->sections, // look for the first non-empty instance of any of those fields ['body', 'html_basic', 'html_full'], // only check sections of the following types ['section_text', 'section_columns', 'section_accordion'], // only check the following nested repeaters recursively ['columns', 'accordion'] ); Wanted to share because I thought it could be useful to others. It should be easy to adjust the matching condition from non-emtpy fields to some other condition, depending on the use case ...
    4 points
  4. https://wiki.php.net/rfc/nullable_types https://www.php.net/manual/en/migration71.new-features.php
    4 points
  5. The new FormBuilder features look very nice, thanks! Lots of questions spring to mind... 1. When using Form A within a Form B, is it possible to override any of the field settings of Form A in the context of Form B? Say, if I was using Form A inside several other forms but I needed one of the fields to be required only within Form B. 2. Is it possible to have show-if and required-if dependencies on fields within Form A that depend on the values of fields within Form B? 3. In a paginated form, are the form values submitted to the server each time Next / Back is clicked? So is each page validated independently and the user cannot move forward until the current page validates, or is all the validation done on the final submit? 4. If each page is submitted/validated independently, can a site admin see partial form submissions in Entries that are abandoned before the final submit button is clicked? 5. Or if the form is only submitted/validated after all pages are completed, how are field errors displayed if they occur on multiple different pages in the form? 6. Is it planned to have an overview navigation of the pagination using the page headings, so a user can jump directly to any previous page in form and can see how far they have progressed through the total form? 7. Do the different pages "know" about the values entered into other pages in the form, so show-if and required-if can depend on values in other pages? Probably I just need to wait until the new version is released. ?
    3 points
  6. Really nice additions to form builder, as an happy customer of Pro Fields I'm going to purchase Form Builder in the next future for a project I'm working on. High five to your new cat! Thanks Ryan, you are a great person.
    3 points
  7. This is a nullable type variable declaration. It simply means $allowed_repeater_types could either be an array or null. https://www.php.net/manual/en/migration71.new-features.php
    3 points
  8. Thanks a lot for this, it might be useful in the future ? Could you please point me where I can learn about the question mark on this line? ?array $allowed_repeater_types = null, I know it should be something about php 7.*, but I cannot find anything due to the fact that the search string "? php" leads, obviously, to wrong results on google ? Thanks!
    3 points
  9. A lot of (even shared) hosting providers nowadays use nginx for static. And you may have no control over which extensions they include. So renaming to .php could be more secure than doing .htaccess restrictions in some cases.
    3 points
  10. Guide how to install ProcessWire on German hoster Uberspace: https://lab.uberspace.de/guide_processwire.html
    3 points
  11. ProcessWire protects what it knows it needs to protect. Blocking everything can be just as annoying especially on e.g. shared hosting where there might be some wordpress site in some subfolder. Or some new favicon file for some new mobile OS to be added to the root. There‘s even a xml file for MS in the mix already. So I feel like e.g. having a list of known sensitive files like .pem/.crt/... blocked would be a nice addition. .phpc is afaik also a often used extension for php. But I‘d not support blocking things beyond that.
    3 points
  12. It was really nice to see you in a video explaining things. The additional capabilities to Form Builder are remarkable.
    2 points
  13. I'm happy to accept PRs ? I'd like to have a dashboard for RockMigrations that makes it easy to see which Migrations where run when, which versions are currently installed etc., but I have not enough time for that at the moment and it could be a lot easier when RockTabulator is ready ?
    2 points
  14. Yes you can. I have something similar for a blogging site. Copy/edit/improve here what makes sense to your case... wire()->addHookBefore('LoginRegister::renderList', function($event) { $links = array(); $defaults = $event->arguments(0); if(user()->isLoggedin()) { if (user()->hasRole('member')) { $links['member-list'] = "<a href='" . $this->wire('pages')->get('/directory/')->url . "'>" . $this->_('Member Directory') . "</a>"; } if (user()->hasRole('author')) { $links['blog-admin'] = "<a href='" . $this->wire('pages')->get('/utilities/blog-admin/')->url . "'>" . $this->_('Blog Admin') . "</a>"; } if (user()->hasRole('admin')) { $links['back-admin'] = "<a href='" . $this->wire('pages')->get('template=admin')->url . "'>" . $this->_('Page Admin') . "</a>"; } } else { if($event->object->allowFeature('register')) { $defaults['register'] = "<p>Don't have an account yet? Members can <a href='./?register=1' class='inline'>" . $this->_("register for an account") . "</a></p>"; } } $links = array_merge($links, $defaults); $event->arguments('items', $links); });
    2 points
  15. Hi @Marc Thx for that interesting question! I've pushed a little update so that RockFinder takes a DatabaseQuerySelect object as find() parameter. You can then add your find as a relation to your finder: Relations can be great for options fields or 1:n relationships. In this case we have 1:1 so a join would maybe make more sense (though have in mind that this creates one more row in the main resultset, so if you had 1000 rows that would mean 1000 more data items whereas in the relation it would be only the number of the templates). You can join ANY sql to your initial finder quite easily. First analyze the query and resulting SQL: We need two things: 1) LEFT JOIN the data 2) SELECT the column we need in the base query Voila ?
    2 points
  16. Thanks everyone for the recent discussion on this - the intricacies of GDPR are not my forte. Sorry, I don't really understand what you are looking for here - I don't think the module should always output a "Manage Your Cookies" - I think this needs to be something that the site developer decides where it should go and how it should be styled. Or maybe I am confused by what you want?
    1 point
  17. Well, you can either write your own valueGetter for this column (very easy) or teach your clients how to double-click ?
    1 point
  18. Thx, one can do a of great stuff with those tools and I think not many know about that... ? But RockTabulator and RockFinder2 will make things a lot easier (if everything goes well).
    1 point
  19. Thanks. (Can't get it to run with my Atom installation.) Because we are a team of eleven and only three of us are devs. The idea is, that we can prepare PW modules for our various client types based on our 20 years of exprience in this particlular industry. After selling, a non-dev PM can select the required modules, install them and essentially have a working site. Al that needs to be done at this point is some templating. Never mind. We'll work around it or write our own extension to RockMigrations. We will definitely extend this. Again: non-dev's invovled. They need to see on the modules page which version is currently installed without having to dig in the files. Thanks for your help. All we need to work out now is testing a FieldTypeRepeaterMatrix and we'r good to go.
    1 point
  20. Those are? It's in the cookie. Saving it server-side would open even more gates therefore some solutions are not GDPR-safe as they save it on their servers. Where is that quote from? By now I have a solution on some of my personal projects that are approved by lawyers to be GDPR-safe and those could collect tons of data... just by one cookie and one click. I paid lots of money to be safe ... so your sources would be really nice as I could get some money back - maybe.
    1 point
  21. Hi, The main breaking change with my version of the module is that Cc/Bcc is ignored if batch mode is set to on. Seemed absurd to me that an email sent to multiple addresses individually would be sent each time to any cc/bcc addresses set. The latest version is compatible with 2.7 onwards. I implemented fallbacks for things (e.g. textTools) not present in the 2 branch. It also has more features and I've been using it in production without issue since I first posted it. However, I've not been using it for much more than sending simple emails. It's fully tested though ? I'd recommend using it if starting a new project, but I'm reluctant for it to be the main directory module as any users upgrading could encounter problems with their existing implementation. They'd be easy to fix, but that's not the point. I don't use any of the Pro modules that it integrates with (FormBuilder, ProMailer), and wouldn't want to interrupt "power" users of these. Perhaps my version should have a different name? WireMailMailgun3 and I could remove the fallbacks for the 2 branch? Cheers, Chris
    1 point
  22. I don't know where those various websites you mention quote their text, the below quote is directly from https://gdpr.eu/gdpr-consent-requirements/: "The GDPR does not indicate a shelf life for consent. Theoretically, a person’s consent is indefinite…" It is a requirement though that a person must be able to revoke their consent at any time. But asking them each time is just bad user experience in my opinion.
    1 point
  23. Thx everybody for pointing that out. Actually I'm quite surprised that those files are not blocked by default ? I'll have to do some refactoring (again) ^^
    1 point
  24. I agree with @teppo - I recently discovered a colleague who was using phpc extensions on a site and he'd left debug mode on. I changed a URL query string value to something invalid which threw an error in a phpc file and I could simply load that file in the browser and view its contents - turns out it contained a payment gateway API secret key. All this because of a non-standard extension that PW's default htaccess file doesn't prevent access to.
    1 point
  25. I wrote a longer reply to the issue mentioned above, but long story short: yes. Currently the contents of these files can be (and by default will be) world-readable, which – depending on the use case, i.e. the code stored in the files – can be considered anything from "probably unexpected but mostly harmless" to "a major issue". As a quick fix you can include a .htaccess file in your module directory preventing access to files with .ready or .hooks extensions, but in the longer term I would definitely recommend refactoring the module to use standard .php extensions instead ?
    1 point
  26. Does it work in the backend? Do you have the latest version (git pull)? It looks like $RockFinder2 api variable is not available for you, but it should (the module is autoload).
    1 point
  27. if you want to see the MSSB in action, these pages all use it: http://www.rogershapirofund.org/blog/ https://www.elliottcarter.com/news/hommage-a-elliott-carter-ensemble-intercontemporain/ https://www.williamanderson.us/blog/manufacturing-innocence/
    1 point
  28. Here's a working example for you: <?php namespace ProcessWire; $showForm = true; if ($input->post->upload) { $tempDir = wire()->files->tempDir('userUploads')->get(); $uploaded = (new WireUpload('uploadedFile')) // same as form field name ->setValidExtensions(['txt', 'png', 'jpg', 'pdf']) ->setMaxFiles(1) // remove this to allow multiple files ->setMaxFileSize(10 * pow(2, 20))// 10MB ->setDestinationPath($tempDir) ->execute(); // $page = $pages->get(1234); foreach ($uploaded as $file) { $filePath = $tempDir . $file; // $page->files->add($filePath); echo $filePath . "<br>"; } // $page->save('files'); if (count($uploaded)) { echo sprintf("Uploaded %d files", count($uploaded)); $showForm = false; } } ?> <?php if ($showForm): ?> <?php // Adding enctype is crucial!! ?> <form method="POST" action="./" enctype="multipart/form-data"> <label for="uploadedFile"> Upload: <?php // suffix name with [] and add multiple attribute if you allow multiple files ?> <input type="file" name="uploadedFile[]" id="uploadedFile" multiple> </label> <div> <button name="upload" value="1">Upload</button> </div> </form> <?php endif; ?>
    1 point
  29. I've read so many websites that I do not want to list that now. Every time I think the GDPR has to be right now, I read something and become uncertain again. Sorry, I forgot the link: https://ico.org.uk/media/about-the-ico/consultations/2013551/draft-gdpr-consent-guidance-for-consultation-201703.pdf Exactly - never ask a lawyer, then it's really long and expensive ? Of course they do that exactly to protect themselves. The problem is that there are so many uncertainties that many points have to be judged first. But I believe that with a legal discussion here we break the question to the module and are off topic.
    0 points
×
×
  • Create New...