jindan

Untitled

Jul 29th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php
  2. define( '_JEXEC', 1 );
  3. define('JPATH_BASE', dirname(dirname(__FILE__)));
  4. define( 'DS', DIRECTORY_SEPARATOR );
  5.  
  6. require_once (JPATH_BASE . DS . 'includes' . DS . 'defines.php');
  7. require_once (JPATH_BASE . DS . 'includes' . DS . 'framework.php');
  8. require_once (JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'factory.php' );
  9.  
  10. define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_BASE . DS . 'administrator' . DS . 'components' . DS . 'com_content');
  11.  
  12. $mainframe = JFactory::getApplication('site');
  13.  
  14. require_once (JPATH_ADMINISTRATOR.'/components/com_content/models/article.php');
  15.  
  16.  
  17. $json_str = array('title 1', 'title 2', 'title 3');
  18.  
  19. $new_article = new ContentModelArticle();
  20.  
  21. foreach($json_str as $row){
  22.     var_dump($row);
  23.  
  24.     $data = array(
  25.         'title' => $row,
  26.          'alias' => time(),
  27.         'introtext' => 'my intro text',
  28.         'catid' => 8,
  29.         'created_by' => 434,
  30.         'access' => 1,
  31.  
  32.     );
  33.  
  34.     $new_article->save($data);
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment