Jump to content

nsc

Members
  • Content Count

    11
  • Joined

  • Last visited

Community Reputation

2 Neutral

About nsc

  • Rank
    Jr. Member
  1. Thanks for this guys, so would you just re-save the page or is there another method to update?
  2. Hi all, I'm still relatively new to the PW world and needed a little help. I've been looking into how to import JSON into new pages and have managed to get that working fine (through help of others posts on the forum). I've got it checking if the page exists (not sure if it's the right way), but am stuck when it comes to updating the page (if it exists). Also, completely stuck when it comes to deleting the page -- if it's not in the JSON anymore. Can anyone help me out/point me in the right direction? <?php $movies = json_decode(file_get_contents('http://www.omdbapi.com/?s=smart&page=1&apikey=xxxxxx')); foreach ($movies->Search as $movie) { $exists = $pages->get("name=$movie->imdbID"); if($exists->id) { echo $exists->id . ' already exists <br>'; } else { $p = new Page(); $p->template = 'single-movie'; $p->parent = wire('pages')->get('/movies/'); $p->name = $movie->imdbID; $p->title = ucfirst($movie->Title); $p->save(); // populate fields $p->event_id = $movie->imdbID; $p->movie_original_title = ucfirst($movie->Title); $p->movie_image_url = $movie->Poster; $p->save(); echo $p->title . ' added <br>'; } } ?>
  3. Solved it by adding the code to init.php instead!
  4. Hi there, Been working with ProcessWire for a while now and have just started having a play with Hooks. I'm trying to generate an email when the page is updated from the front end, although I've only managed to get this to work when updating via the backend. My code in finished.php $this->addHookAfter('Page::changed', function(HookEvent $event) { $m = new WireMail(); $m->to('email@email.com') ->from('email@email.com') ->subject('Page has been changed!') ->body('Content') ->send(); }); Can anyone help out or point me in the right direction?
×
×
  • Create New...