Jump to content

Soma

Moderators
  • Posts

    6,798
  • Joined

  • Last visited

  • Days Won

    158

Everything posted by Soma

  1. Easy just thought this us a important fix. I'll look into it and test. Maybe I can work it out.
  2. Yeah also wanted to mention but thought not overkill the thread. You can use also use the new pw log functions. $log->save("mylog","test") // will save test to mylog.txt
  3. RT @processwire: New module: Soundcloud Embed by @marvinscharle – Transforms SoundCloud URLs into SoundCloud widgets – http://t.co/iwNDnkih…

  4. That's going to be ugly , because there's quite some modules using fancybox and I use it in several project for admin or modules.
  5. Yeah right. I actually found this after messing around with it. And I though ahh, but now looking again I remember what it was: In InputfieldPage #129 https://github.com/ryancramerdesign/ProcessWire/blob/dev/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module#L130 if(in_array($field->inputfield, array('InputfieldPageListSelect', 'InputfieldPageListSelectMultiple'))) { So I can't create a new PageListSelect inputfield. It gives me error Page 1506 is not valid for select_image
  6. As I said, for the page fieldt Currently it's all hardcoded so I can't create a new inputfield for that field.
  7. Great addition! Thanks for your work here. While we are here, how about making the fieldtype page more dynamic for it's inputfields. I tried to add another inputfield type the other day and it's not possible without hacking the core fieldtype.
  8. If your PW install is in the root there's nothing to show.
  9. Ahh... the ProcessPageDelete module by Nico. Works fine here. Again, it depends on what you set the hook, this module does trash the page and not delete it.
  10. I'm not sure what's the issue you're talking about, nor if you want to or use admin to delete pages, as it will trash them and not delete them. So my example is just working for all hooks either trash or delete, just a question if you want the user page to be deleted if the page gets trashed or deleted. Looks ok, you could also use Pages::saved or Pages::saveReady (look at core/Pages.php to read the docs what they're doing), the problem seems more that you're doing a save() in your hook so it will trigger you save hook also. SO it will create user, save user, call save hook, update user. I'm wondering why you don't get a endless recursion (?) That's is simply to prevent recursion or in case the hook get's called multiple times. We could also avoid this differently, but it gets the job done. You could also write: if($page->thispageisalreadyudpated) return; // do nothing $page->thispageisalreadyupdated = true; edit: updated code
  11. Works fine here: $form = $modules->get("InputfieldForm"); $form->action = "./"; $f = $modules->get("InputfieldText"); $f->attr('name','phone'); $form->add($f); $f = $modules->get("InputfieldSubmit"); $form->add($f); if($input->post->submit){ $form->processInput($input->post); $input->whitelist('phone', $form->get("phone")->value); print_r(wireEncodeJSON(array('phone' => $input->whitelist('phone') ))); } echo $form->render(); Outputs: {"phone":"0888 1234"}
  12. In my quick test it works as it should. Maybe I don't understand. 088 1234 isnt a number but s string because of the space. $value = array('test' => '088 1234', 'empty' => ''); print_r(wireEncodeJSON($value)); Outputs {"test":"088 1234"}
  13. Looks cool, thanks for your work here. We got this discussion already to export and import template/fields and I think Ryan said we could build something with json or yaml. I'm not sure anyone else has started something but this could be a start. Just briefly looking at the code it looks good. I'm not sure I understand why you have functions inside a class method? I'm sure it works but seems odd. Also I'm not sure you are aware you can get template and fields with their settings with $field->getArray() $template->getArray() that will return an array with the properties. This might can be used to store them, though not sure it would be of help. wire("templates")->get("basic-page")->getArray(); Would give something like: Array ( [useRoles] => 1 [editRoles] => Array ( [0] => 1006 [1] => 1675 ) [addRoles] => Array ( [0] => 1006 [1] => 1675 ) [createRoles] => Array ( [0] => 1006 [1] => 1675 ) [childrenTemplatesID] => 0 [sortfield] => [noChildren] => [noParents] => [childTemplates] => Array ( ) [parentTemplates] => Array ( ) [allowPageNum] => 1 [allowChangeUser] => 0 [redirectLogin] => 0 [urlSegments] => 1 [https] => 0 [slashUrls] => 1 [altFilename] => [guestSearchable] => 0 [pageClass] => [pageLabelField] => [noGlobal] => 0 [noMove] => 0 [noTrash] => 0 [noSettings] => 0 [noChangeTemplate] => 0 [noUnpublish] => 0 [nameContentTab] => 0 [noCacheGetVars] => [noCachePostVars] => [useCacheForUsers] => 0 [cacheExpire] => 0 [cacheExpirePages] => Array ( ) [label] => [tags] => [roles] => Array ( [0] => 37 [1] => 1006 [2] => 1675 ) ) Also this is possible wire("templates")->get("basic-page")->fieldgroup->getArray(); wire("fields")->get("body")->getArray(); Not sure how about template context settings. Anyway it would be a lot more work if you want to cover all settings.
  14. This works for me $this->pages->addHookAfter('deleted', $this, 'deleteUser'); public function deleteUser($event){ $page = $event->arguments(0); if($page->skip) return; // to prevent multiple calls when using Pages::trash(ed) $page->skip = true; if($page->template == 'student'){ $this->message("Page name in trash $page->name"); $name = str_replace("{$page->id}_", "", $page->name); // strip out the id_ in name $u = $this->users->get($name); if($u->id) { if($this->pages->delete($u, true)) { // maybe recursive in case user has children $this->message("deleted user $name"); } } else { $this->error("user $name not found"); } } } This same code also works with this code $this->pages->addHookAfter('delete', $this, 'deleteUser'); $this->pages->addHookAfter('trashed', $this, 'deleteUser'); $this->pages->addHookAfter('trash', $this, 'deleteUser'); Just depends what you need.
  15. How have you noticed? What 404 page are we talking about? PW default 404 page? It correctly throws an 404 header. It will not (of course) if you access it directly via url then it will be a 200. A 404 in templates, you could write throw new Wire404Exception(); This will render the 404 page and send correct 404 header.
  16. Ok as you said pages in the trash does have their name changed? Does $page->name really match the user page name? Can you get the user if you enter the name there hardcoded? $the_user = $this->users->get("name=hisname");
  17. So going further good coding is not just assuming it will work, often it begins with always checking if you get what you need. if($p->id) { // do soemthing with $p } else { $this->error("Page not found"); } Will always make a huge difference in finding errors or prevent them.
  18. I think it doesn't matter. The question is wether the page get's deleted or trashed (in backend?). In general, I can't stress enough on you guys here that coding is knowing how to debug and try out thing, print out vars, exit or die. I think you would easily find the problem. The more infos you have to more likely and easily you'll find the problem. No fear! Often with hooks it's good to exit("your var $page->name"); or use $this->message("your var $page->name"); so you can see the message and if the hook get's called and output some infos. Most often a NullPage means a get() or find() doesn't find a page and returns a NullPage, so further operations don't work.
  19. I think you need to hook trash() and not delete. Deleting pages in the backed will trash them and not perm delete them.
  20. pwired, you posted now half a dozen links to that webuilder. It's cool you found it and seem to like it but little annoying to have 3 continuous posts of you with the same links to their features list. Apart from that it's not an IDE but a code editor. I almost closed window after reading: "WeBuilder is a faster, smarter and more powerful all-in-one code editor for web developers. Clean interface, ..." I never got why these editors have so many buttons and interfaces (ugly)... then they even write something like: "No clutter WeBuilder is quick, clean and lightweight. It very powerful, yet not stuffed with useless buttons or panels." lol? Looking at their websites code, I think doesn't speak well for them and their editor. I'm so happy I don't have to use such editors and there's these wonderful new editors that focus on what's important. // personal rant over
  21. Soma

    Bookmarking

    Great job on this one! Impressed also on the screencast, very nice to listen to you. I'm just curious for now about caching html. Why didn't you use the MarkupCache feature of PW? Of course your technic using a text field is also nice.
  22. findRandomTimed() returns an array not a single page.
  23. Or use this script I created to create and send a zip to browser. https://gist.github.com/somatonic/6427247 /* creates a compressed zip file */ function create_zip($files = array(),$destination = '',$overwrite = false) { if(file_exists($destination) && !$overwrite) { return false; } if(is_array($files)) { foreach($files as $name => $file) { if(!file_exists($file)) unset($files[$name]); } } if(count($files)) { $zip = new ZipArchive(); if(!$zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE)) return false; foreach($files as $name => $file) { $zip->addFile($file,$name); } $zip->close(); return $destination; } else { return false; } } // get a language to export json files $lang = $languages->get("de"); $files_to_zip = array(); // "language_files" = file field on language page where json's are stored foreach($lang->language_files as $f){ $files_to_zip[$f->name] = $f->filename; } $zip = create_zip($files_to_zip, $config->paths->root . 'language_files_de.zip' ,true); if($zip) wireSendFile($zip); // send file to browser (/wire/core/functions.php) This would be put in a template file. Have fun. While doing this we might need a wireCreateZip() function in core as we also got a wireUnzipFile().
×
×
  • Create New...