Jump to content

Leaderboard

Popular Content

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

  1. Issue #43 filed at GitHub and pull request submitted.
    5 points
  2. Hey @teppo, I've just ran some tests and it seems both saves during inline editting and/or running Page Actions are now properly logged. Thanks!
    5 points
  3. That's strange, and it looks like there's something else (mailserver?) adding the quoted-printable encoding. But I noticed that I haven't based the code above on the most recent version of WireMail, so I'll run some tests myself and try to propose a solution that also takes cases like utf8 characters in names, line wrapping and such into account in an RFC-compatible way.
    5 points
  4. module 1 // define a property protected $userSaved = null; public function ___saveUser($vars){ // add to the class property $this->userSaved = true; } // magic get allows to access private and protected properties too, not only public properties public function __get($what) { if(isset($this->$what)) { return $this->$what; } // or a more restricted and controlled method: $validProperties = array('userSaved', 'someOther'); if(in_array($what, $validProperties) { return $this->$what; } } module 2 public function init() { $this->addHookAfter('module1::saveUser', $this, 'userSaved'); } public function userSaved($event){ $userSaved = $event->userSaved; return $userSaved; // or if you want to change the return value of the originating event, you need to change its $event->return! $changedBooleanValue = true; // do something to calculate the result $event->return = $changedBooleanValue; // pass it back to the hooked event // if you want to access the value that was passed into the hooked method, you get it with $vars = $event->arguments[0]; // there is also a method like: argumentByName or that like, please refer to the docs or code base for it ... }
    4 points
  5. @David Beesley One approach I've used before when importing thousands of records that need to be made into pages, is to stash the data from the external API into a work queue (php-resque or one of the WireQueue implementations) and have cron-initiated workers regularly batch-process a certain number of queue entries, creating pages for them, before exiting. I've done this for a client in the past and it works very well.
    4 points
  6. Do you have $config->debug enabled? If yes, does setting it to false change memory consumption? Also, you may try calling gc_collect_cycles() at the end of the loop after uncaching the page, to allow PHP to garbage collect unused objects with circular references.
    4 points
  7. https://getuikit.com/docs/uikit3.html I like what I see.
    3 points
  8. After seeing your ode, the solution @kongondo pointed at doesn't really apply here because you're not creating a page array, but looping through the data that comes from the API. Any reason why you're not using the same variable to create a page, and to add the fields and save? You would spare a call to the database on each iteraction if you didn't: $page = wire('pages')->get("parent={$parent_page->id}, this_id={$page['id']}"); // where this_id & $page['id'] are this entities id in the api if(!$page->id) { // CREATE new page $page = new Page(); // <- removed the $new_page variable ... // Some generic fields // save $page->save(); // not needed -> $page = wire('pages')->get($new_page->id); } ... // Set some more fields based on API data // save $page->save();
    3 points
  9. I will say, MAMP is super easy to use and I use it with everything I do for local. Setting up processwire is a breeze.
    3 points
  10. The question about behavior is still actual, but for to change it i use this code in init.php $currentLang = $user->language; $pageLanguages = $page->getLanguages(); if(!$pageLanguages->has($currentLang)) { throw new Wire404Exception(); }
    3 points
  11. @BitPoet I owe you an apology. I hadn't turned debug off properly. Once I did that the memory usage held between 25Mb and 40Mb. A drastic reduction
    2 points
  12. Nice one! Seems it's been around since 2.7...so, yeah, newish
    2 points
  13. I know this is ancient, but I just had to do this and discovered a very simple way $pages->emptyTrash(); Maybe this is newish?
    2 points
  14. Yeah, UKit has a lot of cool components. Just hope that it will be build with mixins and functions in the same way as Foundation is built, so we can make our markup more semantic.
    2 points
  15. Okay, thank you. If someone is interested, I have updated the MarkupSitemapXML plugin to ProcressWire 3+ https://github.com/keksmampfer/ProcessWire3-MarkupSitemapXML
    2 points
  16. Thanks for the heads up regrind MAMP - installed that and it was all a breeze. Over and out ;-)
    2 points
  17. I can see two issues there: The Content-Transfer-Encoding needs to be 8bit to support raw utf8 characters The subject needs to be encoded using either quoted-printable or base64 (quoted-printable is most common there, as it leaves parts of the subject readable) Changing the affected functions like this in WireMail.php should get things working with umlauts: public function subject($subject) { //$this->mail['subject'] = $this->sanitizeHeader($subject); $this->mail['subject'] = '=?utf-8?Q?'.quoted_printable_encode($this->sanitizeHeader($subject)).'?='; return $this; } public function ___send() { $header = ''; $from = $this->from; if(!strlen($from)) $from = $this->wire('config')->adminEmail; if(!strlen($from)) $from = 'processwire@' . $this->wire('config')->httpHost; $header = "From: " . ($this->fromName ? $this->bundleEmailAndName($from, $this->fromName) : $from); foreach($this->header as $key => $value) $header .= "\r\n$key: $value"; $param = $this->wire('config')->phpMailAdditionalParameters; if(is_null($param)) $param = ''; foreach($this->param as $value) $param .= " $value"; $header = trim($header); $param = trim($param); $body = ''; $text = $this->body; $html = $this->bodyHTML; if($this->bodyHTML) { if(!strlen($text)) $text = strip_tags($html); $boundary = "==Multipart_Boundary_x" . md5(time()) . "x"; $header .= "\r\nMIME-Version: 1.0"; $header .= "\r\nContent-Type: multipart/alternative;\r\n boundary=\"$boundary\""; $body = "This is a multi-part message in MIME format.\r\n\r\n" . "--$boundary\r\n" . "Content-Type: text/plain; charset=\"utf-8\"\r\n" . //"Content-Transfer-Encoding: 7bit\r\n\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n" . "$text\r\n\r\n" . "--$boundary\r\n" . "Content-Type: text/html; charset=\"utf-8\"\r\n" . //"Content-Transfer-Encoding: 7bit\r\n\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n" . "$html\r\n\r\n" . "--$boundary--\r\n"; } else { $header .= "\r\nContent-Type: text/plain; charset=\"utf-8\""; $body = $text; } $numSent = 0; foreach($this->to as $to) { $toName = $this->mail['toName'][$to]; if($toName) $to = $this->bundleEmailAndName($to, $toName); // bundle to "User Name <user@example.com" if(@mail($to, $this->subject, $body, $header, $param)) $numSent++; } return $numSent; } If the names in From: or To: headers contain umlauts, they also need to be properly encoded. My fix for the subject() function above is a bit crude, as it doesn't care for long lines that should be wrapped. There's also the mb_encode_mimeheader function in PHP which does wrapping but doesn't care for word boundaries and might cause superfluous whitespaces in between words.
    2 points
  18. Similar to above...this nugget by @diogo has served me well in the past... Also, is there a possibility to do it over the command line?
    2 points
  19. @David Beesley Not sure if this will help, but if you are creating pages using some variable, say $p, inside a loop - try telling $pages to un-cache $p at the end of the loop; $pages->uncache($p); Or omit the $p argument to clear all cached pages.
    2 points
  20. An amazingly comprehensive survey on what's cool and what's not. http://stateofjs.com/ Here is the Table of Contents for the Results http://stateofjs.com/2016/introduction/ Take a look through all the sections in the above, but if you are in a rush, most PW folks would probably be most interested in the frontend frameworks section: http://stateofjs.com/2016/frontend/
    1 point
  21. I just published a pre-release of my new password reset module. It will enable identification from any field of your choice, and is fully translatable. Integration is just 2 lines of code, the first is calling the controller, the second is loading a script (no dependencies). You can download the code on GitHub at https://github.com/plauclair/PasswordReset. Also, have a look at the reset process in this video https://vid.me/eEVY. This exemple is not styled, but there should be all you need in there to style it. Comments and feature requests very welcome!
    1 point
  22. Thanks. That was certainly it.
    1 point
  23. With newer PW versions there is, besides a billion other new goodies, also integrated memory checking before trying to manipulate / create a(n) image / variation.
    1 point
  24. You have set private $userName You can set it to public, but only for fast testing, but better: use the magic get method as I showed you in my first post above. You cannot access a private property from the outsite. The function that receives the Event is "the outside".
    1 point
  25. This ancient PR (https://github.com/ryancramerdesign/ProcessWire/pull/954/files?w=1) makes several changes to the comment field for logged in users, including using local profile image, and hiding (and autofilling) the name and the email field. I know it doesn't really help you, but does let you know that others have similar needs I should maybe resubmit the PR to the new Github repo.
    1 point
  26. TracyDebugger - use the Dumps Recorder panel and if you have to, use the "Preserve Dumps" checkbox (although you probably won't need it). Then insert a bd($var) call into your code - easy as pie PS Who uses var_dump anymore
    1 point
  27. CkEditor itself has been around for a very long time and the default editor in PW since July 2014 Before you do anything else, go grab the latest version of PW here: https://github.com/processwire/processwire
    1 point
  28. @Jason Huck - I've added your suggestions to the roadmap (last two points under additional features).
    1 point
  29. PHP's memory limit is an ini setting just like the maximum script execution and set by your hoster. Perhaps you can try with a truly small image and see if this works, just to make sure it is really a case of the script taking too long vs. the script crashing without the CGI handler realising it. If this works, you could try and go up in steps to get a feel where the size limit is. I'm not sure what's the best way to get some sensible debugging information about that, perhaps someone more familiar with the image modules can chime in here.
    1 point
  30. Hey @netcarver Thanks for bringing WireQueue to my attention I'll have a look through the forum thread to see how this could be implemented in my case. @BitPoet I have tried turning debugging off and I end each foreach loop thusly $page = null; // null out page object unset($page); // remove pointer to page object (null) in memory wire('pages')->uncacheAll(); // clear the page cache gc_collect_cycles(); // force invoke the garbage collector But there is no discernible change in memory usage @kongondo I'm unsure how I would implement your example. My page creation process is $page = wire('pages')->get("parent={$parent_page->id}, this_id={$page['id']}"); // where this_id & $page['id'] are this entities id in the api if(!$page->id) { // CREATE new page $new_page = new Page(); ... // Some generic fields // save $new_page->save(); $page = wire('pages')->get($new_page->id); // Set my page object to this new page } ... // Set some more fields based on API data // save $page->save(); (nulling and unsetting omitted for clarity) Thanks all for your help so far. This is a great community
    1 point
  31. No, accessing a variable set in the scope of the hooked method only cannot be accessed. You need to pull it into the classes scope, like I shown in the module 1 example. You may access the passed vars by $event->arguments[n], and if your hooked function has a return value, you can get it and set it like: $resultOfhookedFunction = $event->return; // do some calculation, ... // pass back another result: $event->return = $calculatedResult;
    1 point
  32. Hi. I have some pages wich do not have translation for second language. So i uncheck checkbox for this laguage. Language switcher shows that there is no translation for english, but if i access url site.com/en/about manualy it shows page with deafault language. Is it right behavior? I think that it shoud throw 404 error instead of default language page, because there is no translation = no right content = no page for this url So the question is: does it work like this or Im missing some settings or options? Thank. Best community.
    1 point
  33. @Zeka @tkaranka If this needs fixing in the codebase, could one of you raise an issue for it in either the new ProcessWire issues repository or the requests repository.
    1 point
  34. Here is what I get after the changings from BitPoet: As you can see the subject line at the top works well, but in the body area the German special characters will be replaced by letters and equal signs (for example "ü" will be replaced by "=C3=BC". Also the content type, the charset and the content-transfer-encoding information will be displayed in the content area. Best regards
    1 point
  35. Setting 'requires' => array("LanguageSupport","LanguageSupportPageNames") does not help and this would break the compatibility to single language pages. Using $this->wire("pages")->get($startPage) or $this->pages->get($startPage) makes no difference. Okay i found it. The Page::localHttpUrl hook is defined at ready() and that is too late for this script. For test purpose moving the hook to init() makes the module work. So changing $this->addHookBefore("ProcessPageView::pageNotFound", $this, "renderSitemap"); to $this->addHook("ProcessPageView::pageNotFound", $this, "renderSitemap"); fixes it. Thank you for your time
    1 point
  36. @szabesz : Thanks for the hints. I looked at the several alternatives, maybe I will use it later. For now I have changed the content of the 'Pflanzenhof'- and 'Gartengestaltung'-pages so that the visitors see 'real' content. This seems to be better. If now all visitors with current mobiles are able to see an error-free site I will be satisfied.
    1 point
  37. Hello @Konrad, welcome to the Forums, If I understand you correctly, you have a Bitnami Xampp setup problem, right? Which is at this stage, not yet related to ProcessWire as such. Such an issue fits well our "Dev Talk" section, not this one, but anyway you are probably better off posting such issues here (or maybe a XAMPP community forum?): https://community.bitnami.com/ Do not get me wrong, I do not want to turn you down, you might find someone here with experience in Bitnami/Xampp. I myself have not used it for ages. If you cannot make it work, I recommend MAMP which is relatively easy to get working.
    1 point
  38. to use session based messages or what am I missing? no it's no pw selector, maybe I'll change wording? it enables you to provide a custom link target (useful at all) just pushed 0.1.6 with custom privacy page url
    1 point
  39. Hi @formmailer, I'm not sure if there are better methods, but I have successfully changed a fieldname directly in the MySQL DB. The steps I have done are: open a mysql editor go into rows of table fields find the field in question and change the name in column name last step is renaming the table field_youroldname to field_yournewname That was it. Now I'm able to access it in my templates via $page->yournewname. If you are not able to open that DB live, you may also dump a mysql backup, change the names in it and restore it back, to take effect. (with module ProcessDatabaseBackup, for example)
    1 point
  40. Another solution would be to hook to Inputfield::processInput and change the Input-Data to a full datestring that can be converted from php´s strtotime function. (for example YYYY-mm-dd). (I guess the Datepicker on focus option should be disabled) Here is what I am using in my custom module for DateTime Fields named "date" and "date_to": in init function $this->addHookAfter('Inputfield::processInput', $this, 'processInputDate'); the function public function processInputDate($event) { $inputfield = $event->object; $input = $event->arguments[0]; if($inputfield->name == "date" || $inputfield->name == "date_to") { if(isset($input[$inputfield->name])) { $value = $inputfield->value; if($value && ctype_digit($value) && strlen($value) == 4) { // seems to be only a year, so add 01-01 to it. $value = $this->sanitizer->int($value); $newValue = '01-01-'.$value; $inputfield->setAttribute('value',$newValue); $this->message("Converted ".$value." to a full date string: ".$newValue.")"); } } } } However, I think this makes only sense in certain cases. I need the possibilty to enter also a full date. In my case its okay that the 01. January is some kind of a "special day", where all the items are going wich have only a "year" but no month/day.
    1 point
  41. ... $pwVersion = wire('config')->version; if(version_compare($pwVersion, '3.0.35', '>')) { $pages->addHookAfter('Pages::savePageOrFieldReady', $this, 'saveReady'); // Pages::savedPageOrField(Page $page, array $changes); } else { $pages->addHookAfter('Pages::saveReady', $this, 'saveReady'); if(version_compare($pwVersion, '2.5.9', '>')) { $pages->addHookAfter('Pages::saveFieldReady', $this, 'saveReady'); } } ...
    1 point
  42. @arjen: thanks for notifying me of this. The solution posted by Ryan a bit later (hooking into both Pages::saveReady and Pages::saveFieldReady) should be relatively easy to implement, but the problem is that Pages::saveFieldReady was added in 2.5.10 and this module currently supports >= 2.2. This could mean either jumping through some extra hoops or dropping support for a couple of releases. Anyway, I'll take a closer look at this soon. What would've been awesome was if Pages::saveReady worked consistently across all revisions, but it is what it is
    1 point
  43. That's a very funny and depressing read
    1 point
  44. https://hackernoon.com/how-it-feels-to-learn-javascript-in-2016-d3a717dd577f Just saying.
    1 point
  45. @Fantomas, welcome to the PW forums! I found your post difficult to follow because of the page names you have used in your example. It would be easier to grasp what you're trying to do if you use demo names that can have some meaningful relation, e.g. "Cars", "Model", "Colour", etc. The thing you're asking about is not the basic inputfield dependency feature that this thread introduces, but is actually a feature of Page inputfields. The trouble is that the feature is not formally documented anywhere (grumble, grumble) - it just pops up in forum discussion - so it's difficult to know exactly what is and isn't possible in terms of this feature. As I understand it, the feature only works in the "Custom selector to find selectable pages" (not in "Custom PHP code to find selectable pages") and the reference can only be to another Page field that is in the page being edited. If you're wanting to reference the value of a Page field on a different page then you can do this with FieldtypeReference (and maybe RuntimeMarkup also, not sure).
    1 point
  46. There are basically four different environments to talk about. TemplateFile TemplateFile is core class, which does include your template files, but does also power things like $page->render(), wireRenderFile(), wireIncludeFile() and others. This class will automatically make all API Variables available as local variables. Meaning all those included files can directly use $pages, $page, … . It won't work inside any functions defined in those files, because of the way PHP does scope variables. Classes extending Wire Every class, which is extending the Wire class will have access to API variables via $this->pages, $this->page, if the properties or __get() are not overwritten. Also there's $this->wire('pages'), which is less likely to be overwritten (even some core classes need to use $this->wire()). Anonymous functions There are some methods in the processwire code, which accept anonymous functions as parameters (e.g. WireCache). Those anonymous functions can retrieve api variables as parameters, even though I'm not sure how exactly this is working or if that's often used. Everywhere else Outside of wire classes, template files and special anonymous functions there's the wire() function, which is basically the same as $this->wire() in wire classes, but as a global function, which is accessable anywhere after pw is started. With PW 3.0 and multi-instance this is the option to avoid. Places, which technically are number 2, but it may not be apparent to everybody: Custom PHP code for fields like FieldtypePage or FieldtypeMarkup: As those PHP code is evaluated/run inside those (input)field classes there's (besides manually available local api variables) always the option to use $this->pages or $this->wire('pages'). All those template files included by the TemplateFile class: For the same reason as above there's not only $pages available in those template files, but also $this->pages, $this->wire('pages').
    1 point
  47. The faker api is also really nice to generate dummy data. See the "hosted microservice" section in the readme: https://github.com/marak/faker.js
    1 point
  48. You're welcome. I often use the cheatsheet to lookup stuff: http://cheatsheet.processwire.com/ Maybe the following works: $children = $page->parent->children(); $total = $children->count(); $pagePos = $children->getItemKey($page) + 1; // Assume the keys are zero based
    1 point
  49. I take it you don’t want to show the date the page was created? That would be $page->created. $page->sort gives you the zero-based sort index, but it’s only unique in relation to the parent. This might be the closest to your requirement. $page->id is not necessarily consecutive and starts at 1000, but it’s unique site wide. I believe ProcessWire doesn’t reuse deleted IDs, so they should reflect the order of page creation. However, every new admin page and repeater item will increase this number. Do with that what you will.
    1 point
  50. Something like this should work... $t = $templates->get('basic-page');//get the template $f = $t->fieldgroup->getField('summary', true);//get the field in context of this template $f->description = "This should be the description";//value of the field $fields->saveFieldgroupContext($f, $t->fieldgroup);//save new setting in context Edited for clarity... In this example, we are changing the description of the field 'summary' in the context of the template 'basic-page'.
    1 point
×
×
  • Create New...