Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. public function actionSaveJob()
  2. {
  3. // get 'post to field' mappings from plugin settings
  4. $pluginSettings = craft()->plugins->getPlugin('JobPostPlugin')->getSettings();
  5. $titlePostVar = $pluginSettings->titlePostVar;
  6. $bodyPostVar = $pluginSettings->bodyPostVar;
  7. $summaryPostVar = $pluginSettings->summaryPostVar;
  8.  
  9. // retrieve post data
  10. $title = craft()->request->getPost($titlePostVar);
  11. $body = craft()->request->getPost($bodyPostVar);
  12. $summary = craft()->request->getPost($summaryPostVar);
  13.  
  14. // create a new entry
  15. $entry = new EntryModel();
  16. $entry->sectionId = 2;
  17. $entry->typeId = 2;
  18. $entry->authorId = 1;
  19. $entry->enabled = true;
  20.  
  21. // set entry content
  22. $entry->getContent()->setAttributes(array(
  23. 'title' => $title,
  24. 'body' => $body,
  25. 'summary' => $summary,
  26. ));
  27. $success = craft()->entries->saveEntry($entry);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement