Skip to content

Instantly share code, notes, and snippets.

@protorob
Last active April 9, 2018 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save protorob/e6050c78b4bee2dbce59c38234afa0de to your computer and use it in GitHub Desktop.
Save protorob/e6050c78b4bee2dbce59c38234afa0de to your computer and use it in GitHub Desktop.
Processwire Page Create From Webtic JSON
<?php
$movies = json_decode(file_get_contents('https://secure.webtic.it/frame/wtjsonservices.ashx?wtid=getFullScheduling&localid=1000'));
foreach ($movies->DS->Scheduling->Events as $movie) {
$p = new Page(); // create new page object
$p->template = 'single-movie'; // set template
$p->parent = wire('pages')->get('/programmazione/'); // set the parent
$p->name = $movie->Title; // give it a name used in the url for the page
$p->title = ucfirst($movie->Title); // set page title (not neccessary but recommended)
// added by Ryan: save page in preparation for adding files (#1)
$p->save();
// populate fields
$p->Event_Id = $movie->EventId; // Add event ID
$p->Movie_Original_Title = ucfirst($movie->OriginalTitle); // add multiple to images field
$p->Movie_Type = $movie->Type;
$p->Movie_Category = $movie->Category;
$p->Movie_Year = $movie->Year;
$p->Movie_Duration = $movie->Duration;
$p->Movie_Director = $movie->Director;
$p->Movie_Actors = $movie->Actors;
$p->Movie_Image_URL = $movie->Picture;
$p->Movie_Trailer_URL = $movie->MovieId;
$p->Movie_Description = $movie->Description;
$p->save();
// testing
echo 'id: '.$movie->EventId.'<br>';
echo 'path: '.$movie->Title. '<br><hr>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment