Jump to content

3fingers

Members
  • Content Count

    299
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by 3fingers

  1. if ($child->id === $pid ) { $class= 'active'; // Why are you declaring it here for the 2nd time? } elseif ($template= "memorials" && $child->id === $parents ) { // $template == ... missing double equal sign btw $class= 'active'; } I think you get Undefined because you are overwriting class after the first declaration and then sometimes your if statements never run (depending on false conditions) and so $class is not set at that point.
  2. Very interesting read. Thanks for sharing!
  3. Thanks @Robin S, I'm going to put on my black ninja belt and solve this puzzle.
  4. Thanks @Robin S, I'm trying to get my head around it. if ($input->get->lunghezze) { $lunghezza = $sanitizer->selectorValue($input->get->lunghezze); $input->whitelist->lunghezze = $lunghezza; $tolleranza = ($percentuale / 100) * $lunghezza; $val_up = floor($lunghezza + $tolleranza); $val_down = floor($lunghezza - $tolleranza); //SORT DELTA UP $lun_unsorted_up = $pages->find("variante_prodotto.lunghezza>=$lunghezza,variante_prodotto.lunghezza<=$val_up"); foreach($lun_unsorted_up as $lun){ $lun->delta = abs($lun->variante_prodotto[0]->lunghezza - $lunghezza); } $lun_sorted_up = $lun_unsorted_up->sort('delta'); //SORT DELTA DOWN $lun_unsorted_down = $pages->find("variante_prodotto.lunghezza<=$lunghezza,variante_prodotto.lunghezza>=$val_down"); foreach($lun_unsorted_down as $lun){ $lun->delta = abs($lun->variante_prodotto[0]->lunghezza - $lunghezza); } $lun_sorted_down = $lun_unsorted_down->sort('delta'); } I have more input->get variables, and I'm applying the same concept. At a point in time I "join" all the array I get like this: $insieme = $pages->find("id=$lun_sorted_up|$lun_sorted_down"); // and so on... All good...but, if i put a "limit=20" to the selector (for pagination): $insieme = $pages->find("id=$matches|$lun_sorted_up|$lun_sorted_down, limit=20"); The sorting order is completely gone! Why?
  5. Hey all, I'm facing a problem way over my knowledge right now. Big problem and tight deadline :( Basically is this: $percentuale = 20; // percentace if ($input->get->lunghezze) { $lunghezza = $sanitizer->selectorValue($input->get->lunghezze); $input->whitelist->lunghezze = $lunghezza; $tolleranza = ($percentuale / 100) * $lunghezza; // calculating the tolerance $val_up = floor($lunghezza + $tolleranza); // tolerance up $val_down = floor($lunghezza - $tolleranza); // tolerance down $selector .= "variante_prodotto.lunghezza=$lunghezza, "; $tolerance .= "variante_prodotto.lunghezza>=$val_down, "; $tolerance .= "variante_prodotto.lunghezza<=$val_up, "; } $tolerance .= "template=prodotto_alimentare, sort=variante_prodotto.lunghezza"; /* I want to sort the result from the closest to $lunghezza, but now they are sorted by the smallest to the greatest. */ $matches = $pages->find($selector); $with_tolerance = $pages->find($tolerance); $insieme = $pages->find("id=$matches|$with_tolerance"); foreach($insieme as $product) { //etc... } I'm outputting a series of product which has a particular length ($lunghezza) and also other products which are contained inside a particular tolerance ($with_tolerance). How can i sort the results ($insieme) from the closest to $lunghezza onwards? Right now they are sorted by the smallest to the greatest. Hope to have some feedback from you. Thanks!
  6. Thanks Sergio, you've saved my day!
  7. And this particular post it's the key to success πŸ™‚ Here's the solution: if ($input->get->forme_options) { $san_array = array(); foreach ($input->get->forme_options as $forma) { $san = $sanitizer->selectorValue($forma); $san_array[] = $san; $selector .= "forma_prodotto.title=$san, "; } $input->whitelist('forme_options', $san_array); } My Lord, that was hard! (at least for me :)). Thanks!
  8. Thanks @Sergio but I don't think my problem is related to pagination, infact it works correctly on my side. I think it's rather something to do with whitelist on multiple checkbox (eg. forme_options[] ) which I cannot get it works. Also take a look at my url in my last post above: %5B%5D // I think it's [] encoded, but then it get lost on subsequent pages
  9. @Jan Romero Got success for single values but still have troubles with multi-selection choices (such as checkboxes). I'm trying to solve this way, but without success: // In the code for the form foreach($forme_options as $key => $value) { echo "<li class='icons'><input type='checkbox' name='forme_options[]' value='$value' id='ico-$value'><label for='ico-$value'><img src='{$images->eq($i)->url}'/></label></li>"; $i++; } // Later in the logic if ($input->get->forme_options) { $forma = $sanitizer->selectorValue($input->get->forme_options); $input->whitelist->forme_options = $forma; foreach ($input->get->forme_options as $forma) { $selector .= "forma_prodotto.title=$forma, "; } } In the first page of the result I got this GET query back and results are correct: myurl/?forme_options%5B%5D=rettangolare on the second page (and onwards) i GET this, but the query is lost: myurl/page2?forme_options=rettangolare which looks kinda right, but...no. 😞 Sorry but this is my first "complex" search form with processwire and I'm not really an expert with this. Any clue?
  10. @Jan Romero Just here to say thanks for your detailed answer, is such amazing how much this community surprises me even after years. I'm going to test your suggestion tomorrow at office time, and be back here to mark (hopefully) solved this thread. Thanks again, really really appreciated your effort.
  11. Hey all, I know about $input->whitelist and tried all my way down to solve this problem. Basically the query string get lost in some way on the 2nd and subsequent pages I get this url: myurl/page2?q=WireInputData My eyes and brain got a twist and cannot go further. I post my code in here, if somebody would like to help me figuring it out: Here the form Here the logic Many thanks!
  12. Ok, sorry I didn't know you knew ( πŸ˜€ ). I have no idea why it's not working then....
  13. On the same page you've linked: https://processwire.com/blog/posts/pw-3.0.142/#how-to-setup-and-use-custom-fields-in-file-image-fields basically the "trick" is to use a template without a file named matching the name of your image/s field (eg. field-images where "images" is the name of your image field). Ryan explains it way better in the post btw.
  14. You should check this module: https://processwire.com/talk/topic/11499-admin-restrict-branch but personally I would create a front-end editing per-user page with the necessary form for image and video upload. I don't want users (rather than admins or editors) to access the backend.
  15. Just here to say that I'm the kind of person whom prefer to learn by watching videos, so it would be great if someone could create a series about this topic :)
  16. 3fingers

    About device.js

    For some edgy situations where I cannot solve with just appropriate media queries logic I tend to use Mobile Detect, which uses the user agent string to determine the device in use. One use case for me was the need to swap an html5 <video> with a jpg on iOS devices, due to the fact that I could not autoplay on those devices.
  17. Thanks @adrian and @itsberni, now it's clear what you are doing, thanks for the explanation πŸ™‚ Nice gem from an old blog post too @Jan Romero, I remember I read it once it was published but I forgot it completely. There is so much knowledge "hidden" in the blog which is missing from the docs unfortunately.
  18. Glad you sorted out! But I still don't get the logic where $user->id could match $page->entryPages->id, now I'm the one asking for help πŸ™‚ Maybe @adrian could enlighten my tired brain? πŸ˜›
  19. This comparison, written like this, shoud never return true: if( $user->id == $page->entryPages ) How could a user id match another page id? Are you trying to check if a particular user is the one who created the page you are checking against? In this case you could use $pageToCheck->createdUser where $pageToCheck is your $page->entryPages (still think this is a WireArray and need to be traversed before).
  20. Yes, edited right before your answer πŸ™‚
  21. What kind of field is "entryPages"? I suppose an integer field due to the fact you're comparing with the user->id. And in which situation a user would write inside that field an exact id? ...or, entryPages is a page reference filed, but since it's plural you are dealing with an array of pages, so comparing a single id with an array would never match?
  22. 3fingers

    SeoMaestro

    [Litte OT] @Wanze Out of curiosity, has something changed in your development arsenal? πŸ™‚
  23. Dai amico mio, for the various conspiracies theories Netflix in enough. Once in a lifetime let's think about generosity and collaboration between people, over and beyond their country statuses :)
  24. I previously omitted some of your code for the sake of brevity, so yes, you can do whatever you want inside each foreach iteration.
  25. I think your selector should be: foreach($pages->get("/files/")->children as $folder) { // code for the first iteration, you are now inside the folder foreach($folder->files as $lagu) { // here you are iterating on the files } }
Γ—
Γ—
  • Create New...