oma

Members
  • Content count

    407
  • Joined

  • Last visited

Community Reputation

42 Excellent

About oma

  • Rank
    Sr. Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

3,644 profile views
  1. I'm sure I've seen something like this somewhere in either the modules or on one of @ryan's blog posts but I can't seem to find it anywhere. I current have 6 text fields which are meta details that relate to a project (size, year, location, status etc) – some of them are filled out/used and some aren't depending on the project. On the front-end these fields link up to a label and icon. The client is wanting to add to the list as they see fit (add a label (multi-language), text (multi-language) and icon (image upload)) so my thought would be to add make this into a repeater field – the issue is that most of the original 6 text fields (size, year, location, status etc) are applicable per project so to have to re-add them every time per project to a repeater is a bit tedious. The client also wants to be able to drag/drop the order of these fields so I can't simply create these 6 fixed text fields then add a repeater for extra fields. You see my issue. I'm sure something existed that allowed you to set some pre-defined defaults for a repeater/table then you can add more to them. Ideally, it would be possible to add more, choose the order they appear in across projects, edit headlines, edit icons, and they would be conditional on the front-end based on whether anything was input in them. Let me know if I'm missing something obvious or if this just doesn't exist Thanks!
  2. Thanks, Adrian. I managed to bootstrap in PW and change it all to $session and it worked! Must be that it doesn't like the multiple variables... although it does say this on the $session API page https://processwire.com/api/variables/session/ I hate not knowing why it wasn't working but I had tried and tested everything until using $session worked so perhaps that was just it. Re PayPal... not I'm not... I'm using something similar to this: https://paypal.github.io/PayPal-PHP-SDK/sample/doc/payments/CreatePaymentUsingPayPal.html and https://paypal.github.io/PayPal-PHP-SDK/sample/doc/payments/ExecutePayment.html and relying on the Approval URL. What do you think? Thanks again for all your help.
  3. Thanks for the help, Adrian. I'm really struggling to work this out. Basically I am using the PayPal PHP SDK and upon submission, using $.ajax I am passing the data (which is localStorage) to a page payment__paypal.php (which sits in the directory /api/ alongside /site/ and /wire/. From here I declare the PayPal API stuff and set my $_SESSION['formData'] = $_POST['formData']; and then on redirects to the homepage from PayPal (once successful) where I have <?php require('../../api/redirect__paypal.php'); ?> included in my head.inc. In this file it takes the $_SESSION['formData'] and does a few things with it, or at least it should. If I redirect from PayPal directly to this file (rather than the homepage with the file required) it works fine but for some reason it's not storing the session when I use the require on the homepage (head.inc). If I add $_SESSION['test'] = 'hello_world'; in the redirect__paypal.php file it seems to add it to the $_SESSION if I var_dump it on the homepage so I'm unsure why the $_SESSION['formData'] isn't being saved across? I realise this is perhaps more a PHP issue than a PW one but it's weird it works outside of the non PW page.
  4. Does PW unset the $_SESSION at all?
  5. I'm setting $_SESSION initially out of PW then calling it in head.inc but always returns NULL when returning it. I'm confused too. I could try and use PW's $session within head.inc.
  6. I need to add some saved $_POST data into a $_SESSION. This works fine on a page outside of PW (templates) but isn't returned on any page of PW (within a template or head.inc). I believe this is because $_SESSION is already started. Is there a way to push my $_POST data into the $_SESSION? $_SESSION['formData'] = $_POST['formData']; On a page within PW it is returned as NULL.
  7. Whoa array_chunk is great. That's good to know that PW API doesn't have a chunk method... always try to use the PW methods. Much appreciated and apologies if that felt like a simple PHP question!
  8. Hi folks, I have an image field, that has 50+ images (the total count varies per project) and I want to split them into groups of 15 (so if the total count is 50 the groups would be 15, 15, 15, 5 and if the count is 12 then it just shows twelve). I'd then be keen to loop through each 'group'. Any thoughts how I would do this using the PW API? Is it possible with only the API or would I have to use some non-API PHP? I was thinking I could use splice with a count but unsure if I need to create a new array per group each time?
  9. This is what I had to do... if ($result->next("include=all")->id != 0) { $next = $result->next("include=all")->id; // Next test element in the repeater } else { $next = $result->siblings("include=all")->first->id; // If next doesn't exist (end of repeater rows) then back to start }
  10. This seems to now work... partially if ($result->next("include=all")) { $next = $result->next("include=all"); // Next test element in the repeater } else { $next = $result->siblings->first; // If next doesn't exist (end of repeater rows) then back to start } Only issue is that the if condition isn't returning false or NULL to then go back to start.. it seems to return '0'.
  11. I believe it may have something to do with the ->next() method... https://processwire.com/api/ref/page/next/ // Get the next sibling, even if it isn't viewable $sibling = $page->next("include=all");
  12. Definitely works when logged in and returning values fine... must be a permissions thing.
  13. Yep, it all works when I'm logged in... but when logged out it doesn't. Hmm...
  14. I thought as much but this seems to only work when I'm logged in... <?php if ($this->input->post->action == 'randomTest') : // Get random test ?> <?php $pageID = $sanitizer->selectorValue($this->input->post->pageID); $testID = $sanitizer->selectorValue($this->input->post->testID); $result = $pages->get("id=$testID"); $text = $result->typefaces_detail_tests_text; // Random test text $size = $result->typefaces_detail_tests_size; // Related font size from random test text if ($result->next->id) { $next = $result->next(); // Next test element in the repeater } else { $next = $result->siblings->first; // If next doesn't exist (end of repeater rows) then back to start } return json_encode(['html' => $text, 'size' => $size, 'next' => $next->id]); ?> <?php endif; ?> $('.typeface__toolbar .reload a.trigger').on('click', function(e) { e.preventDefault(); var $this = $(this), pageID = $this.attr('data-page-id'), testID = $this.attr('data-test-id'); $.ajax({ url: rootURL + 'ajax/', type: 'POST', dataType: 'json', data: { 'action': 'randomTest', 'pageID': pageID, 'testID': testID }, success: function(data) { console.log(data); }, error: function (data) { console.log(data); } }).done(function(data) { console.log(testID); }); });
  15. I'm wanting to retrieve a repeater (via it's page ID) and was currently using this (with $testID being the returned repeater item page ID) $result = $pages->get("id=$testID"); This works fine when I am logged in (as superuser) but when logged out it returns null (I guess because it's an admin page). I have tried doing this with no such luck... $result = $pages->get("id=$testID, include=all"); Any ideas? Thanks.