Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


3fingers last won the day on May 24 2017

3fingers had the most liked content!

Community Reputation

243 Excellent

About 3fingers

  • Rank
    Sr. Member
  • Birthday 04/22/1981

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    Turin, Italy

Recent Profile Visitors

4,594 profile views
  1. What about: // Convert a regular array into a WireArray again $wireManufacturers = new WireData(); $wireManufacturers->setArray($manufacturers); Idea comes from here.
  2. Here is my final version, I post it here in case somebody needs it for a similar situation. Read the comment in code. // --Added remove method to the query. I did this because, otherwise, when a user make a 2nd edit to the current page (after the initial save) the "in_evidenza" checkbox would then be reset to 0. wire()->addHookAfter('Pages::saveReady(template=articolo)', function($event) { $pages = $event->object; $page = $event->arguments[0]; if($page->in_evidenza == 1) { foreach($pages->findMany("in_evidenza=1")->remove($page) as $new) { $new->setAndSave('in_evidenza',0); } } }); Could any forum moderator mark this thread as solved? Thanks!
  3. Your improved version works flawlessly, and yes, $pages->$event->object; is needed (error otherwise). Thanks @jens.martsch!
  4. Thanks @psy! Right now my Hook looks like this (I've changed something more from my previous post): /* -- Changed: from Pages:saved to Pages::saveReady. Doing that I can avoid to setAndSave the "in_evidenza" checkbox on the current page. -- Changed: from "find" to "findMany". Even though I actually got few pages to search into, they could grow in the future. I didn't noticed speed improvements, but seems ok. */ wire()->addHookAfter('Pages::saveReady(template=articolo)', function($event) { $pages = $event->object; $page = $event->arguments[0]; $news = $pages->findMany("in_evidenza=1"); $in_evidenza = $page->in_evidenza; if($in_evidenza == 1) { foreach($news as $new) { $new->setAndSave('in_evidenza',0); } } }); I'm still open for suggestions!
  5. Hello guys, I've written an Hook that it's working perfectly right now but I'd like to have some suggestion from you for a possible improvement. Background: - In a template "articolo" I've got a checkbox "in_evidenza". - When a user check "in_evidenza" on a page I want my Hook to set the value of all the other "in_evidenza" checkboxes (inside the other "articolo" pages) to 0. Here is my Hook: wire()->addHookAfter('Pages::saved(template=articolo)', function($event) { $pages = $event->object; $page = $event->arguments[0]; $news = $pages->find("in_evidenza=1"); $in_evidenza = $page->in_evidenza; if($in_evidenza == 1) { foreach($news as $new) { $new->setAndSave('in_evidenza',0); } } $page->setAndSave('in_evidenza',1); }); Right now, as I mentioned, it is working but I've noticed that if i remove the condition (see below) the hooks sometimes works and sometimes the "Fatal Error: memory exhausted" error appears. // Stripped the (template=articolo) selector wire()->addHookAfter('Pages::saved', function($event) { ... }); So I'm here to ask if you know a safer and more efficient way to perform my first Hook, even though right now it's working perfectly (I want to avoid some other memory errors in the future). Thanks!
  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.
  7. 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!
  8. Worth a try: if($config->ajax) { $searchresults = $pages->find("has_parent!=2, title.data{$user->language}"); // See below for the forum link about *.data header("Content-type: application/json"); // Set header to JSON echo $searchresults->toJSON(); // Output the results as JSON via the toJSON function  } else { ... More on that here
  9. Does this works? if($config->ajax) { $language = $languages->getLanguage(); $searchresults = $pages->find("has_parent!=2, $language"); header("Content-type: application/json"); // Set header to JSON echo $searchresults->toJSON(); // Output the results as JSON via the toJSON function } else { ...
  10. Hi Mitlesh, this is the clone of a thread you've opened yesterday, asking more or less the same. That being said if you want another image, wherever you want, you just have to output it inside your code, like you've done with the one you've referenced. Don't forget: 1) you have docs at your disposal. 2) it's august and many of us are away for vacation, so if none replies at your first thread be patient and search the forum for an answer.
  11. Hi @horst, I'm facing similar problems with subscribing a new user to my list, here is my code: (an hook for the LoginRegister module by ryan) wire()->addHookAfter('LoginRegister::processRegisterForm', function($event) { $form = $event->arguments[0]; foreach($form->getAll() as $f) { $name = $f->attr('name'); if(strpos($name, 'register_') !== 0) continue; if($name == 'register_subscribe_newsletter' && wire('input')->post->register_subscribe_newsletter == 1) { $mc = wire('modules')->get("SubscribeToMailchimp"); $email_dirty = wire('input')->post->register_email; $email = wire('sanitizer')->email($email_dirty); $subscriber = [ 'FNAME' => wire('input')->post->register_nome_iscritto, 'LNAME' => wire('input')->post->register_cognome_iscritto ]; $mc->subscribe($email, $subscriber); } } }); And here is what the mailchimp console said about the request: I've tested everything I can imagine (list_id, api key, etc...) but nothing. I've also tried to edit the line 62 of the module with $response = $http->send($api, json_encode($param), 'POST'); but the error still remain.... Did you solved it somehow? Thanks! EDIT: I've solved changing line 54 of the module from: if($status !== false) { //... } to if($status !== 404) { //... } Basically Mailchimp returns a status of 404 (and not false) when the module tries to insert a new user. This is correct because the user is not there in the list at first.
  12. 3fingers


    Thanks @Wanze! I found my solution : wire()->addHookAfter('SeoMaestro::renderMetatags', function($event) { $tags = $event->return; $page = $event->wire('page'); foreach($tags as $key => $value) { if($key == 'image' && $key != '') { $matrix_field = $page->matrix->find('type=immagine_singola')->first(); // immagine_singola is my matrix type $matrix_image = $matrix_field->immagine_articolo->url(); // immagine_articolo is the field inside $tags[$key] = $matrix_image; } } }); I have to refactor something, but for now it's ok. Guys, you rock 🙂
  13. 3fingers


    Thanks for the suggestions, I'm going to work on those and see if I can come up with something useful. +1 for more options for the placeholders, would be even more flexible.
  14. 3fingers


    Hi @Wanze, is it possibile to query a ProField Matrix field (an image in this particular case) as a placeholder for the og:image setting? Something like {matrixfield.imagefield} ? Right now the only images I have inside my templates come from a field of type Matrix. Any solution available? 🙂
  15. Hi @daniels, I'm using your module and I have to thank you a lot, it is saving me hours of time. However I'm facing a problem: if I subscribe a user (goes fine), unsuscribe him (goes fine too) and then try to subscribe him again there goes nothing. He stays with the "Unsubscribed" status inside my Audience section of the Dashboard. How could I try to solve this issue? Thanks!
  • Create New...