Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/28/2016 in all areas

  1. I've never had a blog before - and it's about time I had one now: blog.rockett.pw Introductory post: https://blog.rockett.pw/posts/first ?
    7 points
  2. What $page->get returns depends on the field type, but you'll hardly ever get back a plain array. Btw., $page->get("planos") is the same as $page->planos. For image and file fields, the return value (unless null/empty or set to "Single item") is a PageImages object, which, while it inherits from WireArray and thus implements an iterator so you can run a foreach loop over it, isn't the same as a plain array. If you do need a plain array for some reason (in most cases you won't), you can call getArray() or getValues() on classes inheriting from WireArray.
    4 points
  3. Hi @ukyo and @horst - just another follow up on the suppression of notices/warnings by Tracy. I have discovered that it's because PW image and file uploads use vanilla JS calls that don't use xhr.getAllResponseHeaders(); This prevents Tracy from being able to update its AJAX debug bar with any notices/warnings returned from the AJAX request. I have just posted an issue (https://github.com/processwire/processwire-issues/issues/137) in the hopes that Ryan will consider adding xhr.getAllResponseHeaders(); to both of these. I have tested here and it works great and I actually think it will be of great benefit to beginners debugging image/file upload problems who aren't used to looking for AJAX errors in the Network panel of the browser dev console because now any notices/errors will appear very obviously on the Tracy AJAX debug bar. If you're willing, I'd love a show of support for this change on that Github issue. Thanks!
    3 points
  4. I see, that's of course different, and - since there's no direct relationship between two image fields - doable but dangerous in case one of the images is missing, and keeping then in sync isn't easy once the list gets long. $precioschico = $page->get("planos"); $preciosgrande = $page->get("mapas"); for($i = 0; $i < $precioschico->count(); $i++) { $chicoimg = $precioschico->eq($i); $grandeimg = $preciosgrande->eq($i); echo " <div class='col-md-6 col-lg-4'> <a href='{$grandeimg->url}' class='thumbnail' rel='prettyPhoto[galeriaplanos2]'> <img class='img-responsive' src='{$chicoimg->url}' /> </a> </div> "; } To make the code a little simpler and avoid errors by images not matching up, you might consider creating a repeater field with two image fields (one named "grande" and one "chico", each set to "Single item"). Then you could run a simple loop over your repeater field. foreach($page->repeaterimages as $img) { echo " <div class='col-md-6 col-lg-4'> <a href='{$img->grande->url}' class='thumbnail' rel='prettyPhoto[galeriaplanos2]'> <img class='img-responsive' src='{$img->chico->url}' /> </a> </div> "; } If you set the column width for both image fields to 50%, you can show and edit them side by side in the repeater list on the page. The page editor would look like this:
    3 points
  5. No, this is not needed, because the method redirect() calls "exit(0);" at the end. See class: https://github.com/processwire/processwire/blob/master/wire/core/Session.php Docs: https://processwire.com/api/ref/session/redirect/
    2 points
  6. Those variables are always available to you. You don't need to do anything special. The one care you should take is not to overwrite them. # outside a function // will echo the integer value of an input called 'id' that was sent via $_GET echo (int) $input->get->id; // will echo the sanitized value of an input 'title' that was sent by $_POST echo $sanitizer->text($input->post->title); If in a function then: # inside a function // will echo the integer value of an input called 'id' that was sent via $_GET echo (int) wire('input')->get->id; // will echo the sanitized value of an input 'title' that was sent by $_POST echo wire('sanitizer')->text((wire('input')->post->title)); Of course, if inside a function or class, and you will be using lot's of wire('input'), then you can assign that to a variable at the start of the function/class method, i.e. $input = $this->wire('input')->post;// #1. if expecting only post variables // or $post = $this->wire('input')->post; $input = $this->wire('input');// if expecting either get or post or cookie // or $input = wire('input');// you get the idea // then, in relation to #1 above, you can do $id = (int) $post->id; If you have a specific issue, please address it. What is working? What is not? etc... http://processwire.com/api/variables/
    2 points
  7. Just to have a reference. There is a native PW way to generate random string. Do not know how it compares to other ways, but it is here to use.
    2 points
  8. $config->httpHosts whitelisting will not prevent processwire from rendering the page, but only $config->httpHost will not match the actual domain if it's not a whitelisted one. So the issue you're having are probably not related to processwire but rather to your domain / webserver setup. The latter can include the settings in the .htaccess of processwire.
    2 points
  9. Thank you for your best-in-class support.
    2 points
  10. I think you are much better off defining distinct "styles" for Ckeditor rather than allowing full manipulation - if you give editors free reign to change colors, you're likely to end up with a really ugly site. You can read more about setting up styles here: https://github.com/processwire/processwire/blob/dev/wire/modules/Inputfield/InputfieldCKEditor/README.md#custom-editor-css-file
    2 points
  11. I updated my module on my local works, didn't update repo yet. I will update module as soon as possible.
    2 points
  12. ProcessPageListerUrls Create links to specific ListerPages with predefined selector, column and sort settings. See GitHub for more information. Download ProcessPageListerUrls on GitHub
    1 point
  13. Hi, it seems that `item_content` only apply to inputfields of type InputfieldWrapper and InputfieldPage. If you use something like `_init.php` you can add a hook there: $this->addHookBefore('Inputfield::render', function(HookEvent $event) { if ($this->page->template->name === 'contact') { // adapt template name to compare with $inputfield = $event->object; $inputfield->addClass('col-sm-8'); $event->return = $inputfield; } });
    1 point
  14. Welcome to PW and the forums @webhoes, I didn't go through your whole code but noticed this: if (waves = 0)//....... That's not a comparison but an assignment. Should be if (waves == 0)//.... // or....depending on your needs if (waves === 0) //... Other than that, you might want to separate the PHP from JavaScript. E.g. for the checked input..., in a foreach loop, assign a CSS class, e.g. 'checked-input' and use that to find elements that are checked.
    1 point
  15. In a previous version, the _init.php was automatically added unless otherwise selected in template - files tab. That's what caused my troubles. Thanks for directing me to the solution!
    1 point
  16. Unless you are in a PHP Class, you should not be using $this at all, as pointed out earlier. You don't need this line at all: //$wire = $this->wire();// this is not needed in your context It is a good idea, to get a few basic PHP tutorials under your belt before starting to use ProcessWire . Given that you are setting up something as important as a user registration feature, I highly recommend you have a look at such tutorials.
    1 point
  17. Looking at the languages site profile, there is no _head.php file: https://github.com/processwire/processwire/tree/dev/site-languages/templates Maybe you are combining files from different profiles? Regardless, the key thing is that $homepage is null so you need to define it somewhere before the line that calls the getLanguageValue on it. Currently the languages site profile does this in the _init.php file: https://github.com/processwire/processwire/blob/e12095e622555fe79cd792dea1ed7d671e37d9d4/site-languages/templates/_init.php#L26
    1 point
  18. ProcessWire's WireMail base class https://processwire.com/api/ref/mail/ https://processwire.com/api/ref/wire-mail/ Example third-party module implementations http://modules.processwire.com/modules/wire-mail-swift-mailer/
    1 point
  19. A couple of examples Outside function and class $page; $pages; $sanitizer; $input; $modules; $templates; $fields; $user; $users; $log; $session; $config; Inside function wire('page'); wire('pages'); wire('sanitizer'); wire('input'); wire('modules'); wire('templates'); wire('fields'); wire('user'); wire('users'); wire('log'); wire('session'); wire('config'); Inside class $this->wire('page');// also $this->page; $this->wire('pages');// -ditto- $this->wire('sanitizer');// -ditto- $this->wire('input');// -ditto- $this->wire('modules');// -ditto- $this->wire('templates');// -ditto- $this->wire('fields');// -ditto- $this->wire('user');// -ditto- $this->wire('users');// -ditto- $this->wire('log');// -ditto- $this->wire('session');// -ditto- $this->wire('config');// -ditto- Welcome to PW and the forums You may also want to use PW core email class + read up on the recent vulnerability regarding PHPMailer Class (if you haven't already)
    1 point
  20. * updated : PhpMailer 5.2.19 module updated also in githup repo and module directory
    1 point
  21. Thanks LostKobrakai, I have just spoken to my hosting provider and there was a DNS issue, all fixed now.
    1 point
  22. $wire = $this->wire(); $this is only used inside a class. http://stackoverflow.com/questions/1523479/what-does-the-variable-this-mean-in-php
    1 point
  23. Hi @Ivan Gretsky - I've added some options for controlling the automatic backup (not committed yet) and I am thinking about the guest user access for making calls to actions via the API. I am considering a couple of different options and will put together something in the next couple of days. Hope that works for your timeframe?
    1 point
  24. Another update which now also fixes bd() and all other calls from the Console Panel when the SessionHandlerDB module is installed - the AJAX bar will be immediately updated now. I think we can now declare that there are no outstanding issues with that module, but please let me know if any of you come across anything I have missed!
    1 point
  25. There was a security alert on Christmas about PHPmailer (older than 2.5.18, latest is 2.5.19): https://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10033-Vuln.html
    1 point
  26. There was a security alert on Christmas about PHPmailer (older than 2.5.18): https://legalhackers.com/advisories/PHPMailer-Exploit-Remote-Code-Exec-CVE-2016-10033-Vuln.html
    1 point
  27. Thanks for sharing your module with us. I use it to mark events which are booked up.
    1 point
  28. @lena In the module docs you can find instructions on how to apply your custom markup/classes: https://github.com/justb3a/processwire-simplecontactform/blob/master/doc/overwrite-classes-and-markup.md EDIT: and welcome to the forum!
    1 point
  29. Yes it is... Instead of using composer just download the 2 libraries: Google recaptcha for validating the user is not a robot (https://github.com/google/recaptcha) Valitron validation library for validating the form fields (https://github.com/vlucas/valitron) unzip them inside a folder ...and replace the lines: include(dirname(__FILE__) . "/../../vendor/vlucas/valitron/src/Valitron/Validator.php"); include(dirname(__FILE__) . '/../../vendor/google/recaptcha/src/ReCaptcha/ReCaptcha.php'); with: include(dirname(__FILE__) . "yourfolder/vlucas/valitron/src/Valitron/Validator.php"); include(dirname(__FILE__) . 'yourfolder/google/recaptcha/src/ReCaptcha/ReCaptcha.php'); Hope it helps! Actually composer doesn't do any magic...it just downloads the libraries inside the vendor folder but you can always do it manually if you want.
    1 point
  30. I've just tagged 0.3.0-RC1 on Github. I've replaced league/climate with symfony/console to allow for more advanced parameter parsing => nicer commands. Documentation on the new cli commands by now can be found running migrate or migrate [command] -h. The commands migrate/rollback do now support multiple arguments from the cli as well as via the processwire module: integer: migrate/rollback that number of files filename (/path, but does fallback to filename comparison) classname * : migrate/rollback all ("*" in the terminal) In addition to that does migrate also have an option to only use "latest" migrations, which are the ones newer than the latest migrated file instead of all files not migrated. Other changes: Made the mysql table name lowercase to prevent issues with case sensitivity. Migration files are now managed via custom WireData/WireArray classes, which made the code quite a bit nicer than passing around just filenames. Custom migration templates can be put in /site/migrations/templates/. These can be created via migrate create:custom -t [type]. I'd appreciate it if some of you guys could take a look at it if there are any issues I've missed.
    1 point
  31. I hope people see the funny side of it
    1 point
  32. thanks for mentioning @LostKobrakai good to know right markupcache was the thing I was thinking about @adrianmak glad you solved it yourself, actually I forgot that I got my ready.php kind of split, first code blocks are intended to run on back and front end, like save hooks and stuff, then i got this code if ((strpos($page->url, wire('config')->urls->admin) !== false) || ($page->id && $page->is('parent|has_parent=2'))) return; i think i found this or something similar somewhere in the forums, am not entirely sure if the second part is really needed as the first part checking if url contains admin path (usually processwire) you could extend it by placing / before and after and I don't know if there are any possibilities of admin pages not containing admin url.. anyway, everything after this line will only run on front end..
    1 point
  33. This is not the right way to get the url of a single image. When using image fields you want to select the "Formatted value" setting that suits the number of images your field is allowed to hold. I recommend you stick to two of these options: Array of items - select this when "Maximum files allowed" is set to either 0 (no limit) or greater than 1 Single item - select this when "Maximum files allowed" is set to 1 Next you need to understand what is going to be returned when you use $page->image (assuming your image field is named 'image'). If you chose "single item" then $page->image will be a single image object. If you chose "array of items" then $page->image will be an array of image objects. You don't want to ever echo an object itself (it may return some value but it's generally not good practice), but you might echo some property of the object (e.g. description) or call some method on the object (e.g. url or size). When dealing with an array of image objects you will either loop over them with foreach or you can get a single object from the array with a method such as first() or eq(). So take this code example from above: You want to get the URL of a single image in the field. If your image field is formatted as "single item" then you would do this: $image = $page->image->url; If your image field is formatted as "array of items" then you would do this: $image = $page->image->first()->url; One more thing... You are setting width and height attributes on the img tag so you should use the size() method to make sure the image is cropped to the same dimensions (or same ratio of dimensions if you are wanting a HiDPI image). $page->image->size(600,480)->url Otherwise you wont get the desired result if someone uploads an image with a different aspect ratio.
    1 point
  34. @Ivan Gretsky, there is a crypto module here that can create random token strings for you. If I remember correctly, you can just do this; $num_chars = 32; // The length of the token you want. Adjust as needed $random_key = CryptoPPP::genKeys(1); // Generates a seed key $token = CryptoPPP::keyToToken($random_key, $num_chars); // Convert to string token You can also define the character set that the random string is to use if you aren't happy with the default one. In fact, if you are going to use the token in a returned link, you'll definitely want to change the default character set used in the generation to only use url-safe characters.
    1 point
  35. thank you elabx, that was my intention as i'm quite new to hooking and already find my way through the basics but i think it could be very handy to click a button in backend and have all the called hookable methods showing up somewhere. maybe with some helpful information inside a toggleable div (like pageid/title from the triggering page or descriptions from above the medhod (maybe links to github like this one for pages::saveReady(): https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/Pages.php#L2086) edit: github won't be a good idea because it should show the info of the currently installed version of processwire so it would be better to fetch the information directly from the file system.
    1 point
  36. The ModuleJS::init() takes care of loading those scripts if they have the same name as your module, so you don't need to overwrite this method. Edit: If you need to append additional JS/CSS, call parent::init() first
    1 point
  37. The audience for making Process modules is small enough that time for documentation is getting put towards broader scope stuff first. I think there might just be 4-5 of us that have an interest in making Process modules. But this will be in the documentation at some point, especially as interest for it grows.
    1 point
×
×
  • Create New...