Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. // Get the movie for the show we try to add from array of all movies
  2. $movieEntry = $movies[$showEntry->movieID];
  3.  
  4. // Get the currently listed shows from the movie
  5. $movieEntryShows = $movieEntry->shows->ids();
  6. // Add show if not already there
  7. if ( !in_array( $showEntry->id, $movieEntryShows ) ) {
  8. array_push( $movieEntryShows, $showEntry->id );
  9. }
  10.  
  11. // Set updated list of shows back to the movie
  12. $movieEntry->setContentFromPost(['shows' => $movieEntryShows]);
  13.  
  14. // Save movie
  15. $success = craft()->entries->saveEntry($movieEntry);
  16.  
  17. $test = ['1288', '1299', '1291'];
  18. $movieEntry->setContentFromPost(['shows' => $test]);
  19. $success = craft()->entries->saveEntry($movieEntry);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement