Jump to content
NorbertH

IftRunner only in backend ?

Recommended Posts

When saving a page with the "order" template in the backend  IftRunner is nice to me and sends the order via page action into my accounting software. 

When saving "order" in a frontend page it does nothing.   So i certainly missing something . Any ideas? 

 

Share this post


Link to post
Share on other sites

@NorbertH Are you sure there were changes to the order page when you saved it in the front-end. IIRC, there needs to be a change to a field before the save actually activates an Ift action. 

Share this post


Link to post
Share on other sites

Almost 100 % sure fetching all vars from a form, and put them into the page.

Creating an empty page  , so i can add Profields Table (You cannot add this to a not saved page), set some other values like customer and delivery address , set the table with products and then save it again. 

        // Create page
		$b = new Page();
		$b->template="bestellung";
		$bId= $b->save();
		
		// Set basic stats
		$b->bestellung_user_select=$derCustomer;
		$b->bestellung_liefer_addresse_select=$pages->get((int)$input->post->liefer_select);

		if ($input->post->liefer_select=="3826" OR $input->post->liefer_select=="3827")
			$b->bestellung_status_select=$pages->get(3829); // status Barverkauf
		else
			$b->bestellung_status_select=$pages->get(1047); // status bestellt
		
		$b->bemerkung_area=$bemerkung_area;
		
		
		// Add articles (bestellung_artikel_table)
		//$b->of(false); // turn off output formatting
		foreach($myProducts as $prod) { 								
			if (!empty($input->post->artikel[$prod->id]) AND 0< (int)$input->post->artikel[$prod->id]){
				$art= $b->bestellung_artikel_table->makeBlankItem();
				$art->artikel=$prod;
				$art->stueck=$input->post->artikel[$prod->id];
				$b->bestellung_artikel_table->add($art);
				$b->save('bestellung_artikel_table');
			}
		}
		
		// save it all  
		$b->save();
		
		// Show order successfull
		$okBestellt=true;
	
		// Finally delete the post array , so the form is ready to go again  
		$_POST=array();    // Global Post array
		$input->post=null; //  Processwire post 
		$aStueck=array();
		$bemerkung_area="";
	
	} // END of order

Very simple indeed. But it does its job. (Orderpage is just a simple frontend page) 

Edit:

Btw. have no changing field defined so it should not look after changes ?
In the BE it kicks in without any changes.

As a test workaround i simply made a CLI script that simply loads all pages that are not send , and then saves them again. the Hook then kicks in and sends the pages as he should.  

$result=$pages->find('template=46, deny_export=0, bestellung_stueckzahl!="", bestellung_user_select.count!=0, bestellung_liefer_addresse_select.count!=0, bestellung_id_collmex="", limit=2');

foreach ($result AS  $p) {
    echo $p->name."\n";
	$p->save();
}

 

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By longtom
      I'm creating this site where a 'motherpage' renders all subpages.  I switched on frontend editing to make editing as easy as possible to end-users. 
      I'm stuck on adding images to the subpages.  The frontend editor suggests to add images to the motherpage (that has no images field on it, nor should it), so it asks for another page to add the images to/from. 
      Is there a way to make the frontend-editor context aware so that it looks for images in the correct subpage? 
      I already tried the 'type C' approach and added <edit field="body" page="id">, but that doesn't seem to do the trick. 
    • By rushy
      Hi all
      Continuing my first project where I am creating and manipulating stuff from the frontend. Till now I've always added things like images from the backend, but in this project I need to add and move images from a frontend control. This is a photo album where images are stored in albums, each album being a page containing a Pageimages array in the usual way. So what I want to know is how do I move an image from one album (page) to another in the frontend? I just need some guidance on how to approach this.  I suppose I need to do a copy and delete - but how do I copy an image or images from one page to another? What function should I use to create a new image on an existing page? I include a code snippet from the server side of my delete image request and it works fine. I'd like to implement something similar for a move and upload new image request. 
      Many thanks for any help. Paul 
      <?php namespace ProcessWire; // sanitize inputs as 1-line text $action = $sanitizer->text($input->post('action')); $instr = $sanitizer->text($input->post('input')); $sel = $input->post('selected'); // Expect JSON for image selected image list $selected = json_decode($sel); $nosel = count($selected); $response = array(); // for building JSON response switch($action) { // delete selected images case 'delete': $out = "<p>Deleted $nosel image(s)</p>"; foreach($selected as $item){ $album = $pages->get($item->album); $album->of(false); $out .= "<p>Image {$item->file} from album {$album->title}</p>"; $album->images->delete($item->file); $album->of(true); } $out .= saveUpdatedAlbums($pages, $selected); // add the response message for the delete $response['message'] = $out; break; ...... // save any album that had an image deleted function saveUpdatedAlbums($pages, $selected) { $cur = ''; $out = ''; foreach($selected as $item){ $album = $pages->get($item->album); if($album->id != $cur) { $album->of(false); $album->save('images'); $album->of(true); $cur = $album->id; $out .= "<p>Updated album {$pages->get($cur)->title}</p>"; } } return $out; }  
       
       
    • By hellomoto
      I can't tell what's wrong; my local development version appears just fine, but I copy over the site files and db online and the homepage content is not being contained. This is what it should look like (same site in the same browser, running on my localhost): http://imgur.com/UFZFzrd
      What could be the problem here? Sorry to bring up something so irrelevant to PW here, I just know that you all are a valiant and helpful group, and no one on StackExchange seems to even know what I'm talking about.
      Thanks a lot.
    • By rushy
      Bit of a newbie type question, even though I've been using PW for quite a while, I've not had to manipulate assets from the front end before.  I now have a need to update image properties from the front end and I'm trying to update an image description and tags when clicking on a link. I get the selected image and for example I can delete it with the code below. But I am missing some basic understanding when updating image description field as nothing happens, no errors but the description field remains empty. Any idea what steps I am missing? Many thanks. 
      // how to update image description? $al = $pages->get($album); $pgfile = $al->images->getFile($file); $al->of(false); $pgfile->description = "Test description"; $al->save(); // to delete an image - this works $al->of(false); $al->images->delete($file); $al->save();  
    • By SwimToWin
      ProcessWire is setting a "wires" cookie for each guest session.
      Is it possible drop that cookies, so there are no cookies at all for guests?
      That way, I don't need to spam the user with a cookie consent box.
      I don't need cookies for user preferences and marketing purposes.
      (Why are cookies being set by default in the first place?)
×
×
  • Create New...