Tom.

Members
  • Content Count

    397
  • Joined

  • Last visited

  • Days Won

    6

Tom. last won the day on September 5

Tom. had the most liked content!

Community Reputation

516 Excellent

About Tom.

  • Rank
    Sr. Member
  • Birthday 11/01/1992

Profile Information

  • Gender
    Male
  • Location
    England
  • Interests
    ProcessWire

Recent Profile Visitors

2,943 profile views
  1. Thank you all for your responses. This does in fact help! Turns out it wasn't a curl issue but trying to store and XML object as a session.
  2. I'm using PW's $session. function post_curl($url, $data) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $response = curl_exec($ch); curl_close($ch); return $response; } $token = $pages->get("template=foxycart")->token; if($_POST['ThisAction'] == "CheckLogin") { $login = post_curl("https://teatumjones.foxycart.com/v/2.0.0/api_json.php", $_POST); if($login) { $json = json_decode($login); if($json->ok === true || $json->details == "Transaction not found") { // Set session to logged in. $session->logged_in = true; // Find user from FoxyCart and store as session. $user = post_curl("https://teatumjones.foxycart.com/api", array( 'api_token' => $token, 'api_action' => 'customer_get', 'customer_email' => $input->post->customer_email) ); $xml = simplexml_load_string($user); $session->customer_id = $xml->customer_id; } else { echo "User or Password incorrect."; } } else { echo "Unable to reach login server at this time."; } } Interestingly, the $session doesn't get removed if I don't use $session->customer_id = $xml->customer_id; I can use in it's place $session->customer_id = "Hello"; and that will be remembered. As soon as any $sessions are set using the $xml data. It just completely forget's all sessions set on that file.
  3. I was wondering if anyone else has come across this? I'm wanting to store information from a cUrl request in a session. The cUrl goes to an external API and does a POST request. I'm wanting to store the session ID after using curl, but I've found that setting any $session after cUrl will cause it to forget all $session set if you leave the page. It's such an annoying, weird thing that PHP does. I've tried using httpWire but that doesn't store the $session but at least it doesn't forget all other session data. Interestingly, the session is only reset if I try to use any of the data from the cUrl and store it in a session. Even if I set the response as a variable first.
  4. Hi @flydev To give a better example. Array 1 (All Pages): array( PageObject(1140), PageObject(1141), PageObject(1142), PageObject(1143) ) Array 2 (Updated Pages): array( PageObject(1140), PageObject(1141) ) Return Array: array( PageObject(1142), PageObject(1143) ) Basically, I want to compare array 1 with array 2 and get rid of things that exist in the array. PageObject is just a page item and (1233) is the page ID. I just made this up for example but it will be a PageArray instance.
  5. Hey, I have a complex bit of code that is working with product variations. I loop through variations that need to be updated (when modifying the variations in any way). I store these in a PageArray() and then I need to compare it against a list of pages. In this instance ->not() would work great, however it expects a selector. It needs to be an $item. What I'm trying to do is to remove a set of items from a list of other items using the API, using remove() or removeItems() deletes the repeater item, it doesn't remove the items from the array.
  6. Tom.

    I believe that ProcessWire automatically sorts out duplicates so you could do $Cats = $pages->find("parent=1086, id!=$page, sort=sort"); $Cats->prepend( $Cats->eq(4) ); foreach($Cats as $Cat) { }
  7. Tom.

    Hi @Nils Wiere If that is the exact code, there is a few issues. $pages->find("brand.title"); I believe will return any page that has a field brand assigned to it. You aren't referring to a specific template. You are also not telling it anything to search. I believe the code you are looking for is as follows. $brand = $page->title; $products = $pages->find("template=brands, brand.title=" . $sanitizer->selectorValue($brand) ); // OR If you want to avoid searching within a template. $products = $pages->find("brand.title=" . $sanitizer->selectorValue($brand) );
  8. I never knew that, I wonder why guests have permissions to view unpublished pages? Anyway, I guess put this at the very top of your template file: if($page->isUnpublished() && !$user->isSuperuser()) throw new Wire404Exception();
  9. Tom.

    It would be really good if image->add had a second argument for image name
  10. Tom.

    I believe it's an issue with DropZone. I've decided to do the following: if(count($_FILES['file']) == 0) { $error = "Please upload your entries."; } else { $count = count($_FILES['file']['name']); for($i = 0; $i < $count; $i++) { $file = $p->images->path . $sanitizer->pageName($_FILES['file']['name'][$i]); if(move_uploaded_file($_FILES['file']['tmp_name'][$i], $file)) { $p->images->add($file); } } } if(!$error) $p->save(); Which works a charm Thanks @bernhard
  11. I have a script that I would like to upload and make sure the files keep it's file name. This is a multi-image image field. Just using $p->images->add($_FILES['file']['tmp_name']) works. However this doesn't: if(count($_FILES['file']) != 0) { $p->images->removeAll(); $u = new WireUpload('file'); $u->setDestinationPath($p->images->path); foreach($u->execute() as $filename) $p->images->add($filename); } if(!$error) $p->save(); There is no error given, however non of the images are added? What am I missing here? Edit: print_r($u); print_r($u->execute()); Both return an empty array. I'm guessing WireUpload('file') doesn't use $_FILES and there for can not be used with DropZone? Edit2: WireUpload does use $_FILES. There is some sort of bug happening here with using Ajax and WireUpload.
  12. @Zeka There is many inconsistencies between in-memory and DB. Things being case sensitive etc. I'm recently seeing the inconsistency throw people more and more. As the API is the same - I think it's hard to know what's going to be DB and what's going to be in-memory. I think there are things that can be done to bring in-memory searches to bring it inline with DB searches. For now this should work: <?php $validation = []; preg_match_all('/\(([^\)]+)\)/' $selector, $matches); foreach($matches[1] as $match) { $validation[] = $page->matches($match); } if(in_array(true, $validation)) { // Page Matches one OR Group. } ?> I haven't tested it, but it should work, might require a little tweaking. Or <?php $validation = false; preg_match_all('/\(([^\)]+)\)/' $selector, $matches); foreach($matches[1] as $match) { if(!$validation) { $validation = $page->matches($match); } } if($validation) { // Page Matches one OR Group. } ?>
  13. I'm integrating FoxyCart SSO at the moment, I want to make it so when someone registers using ProcessWire it also registers them for the Store. To do this I have to set FoxyCart up to use the same encrypting method as ProcessWire. I know it uses a hash and a salt. But I was wondering if anyone has done this before? I'm struggling to utilise the ProcessWire API to pass FoxyCart the hash and salt for a particular user.
  14. Tom.

    Worked a charm - thanks! EDIT: Spoke to soon, in this case it must be = because if you have an empty selector that means that product variation doesn't exist. So selecting colour=blue isn't enough, but *= will still make a selection.