Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Get the movie for the show we try to add from array of all movies
- $movieEntry = $movies[$showEntry->movieID];
- // Get the currently listed shows from the movie
- $movieEntryShows = $movieEntry->shows->ids();
- // Add show if not already there
- if ( !in_array( $showEntry->id, $movieEntryShows ) ) {
- array_push( $movieEntryShows, $showEntry->id );
- }
- // Set updated list of shows back to the movie
- $movieEntry->setContentFromPost(['shows' => $movieEntryShows]);
- // Save movie
- $success = craft()->entries->saveEntry($movieEntry);
- $test = ['1288', '1299', '1291'];
- $movieEntry->setContentFromPost(['shows' => $test]);
- $success = craft()->entries->saveEntry($movieEntry);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement