Created
September 17, 2013 11:04
-
-
Save dilantha/6592883 to your computer and use it in GitHub Desktop.
Some WordPress import code in Laravel 3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Import_Controller extends Base_Controller { | |
public $restful = TRUE; | |
public function get_index() | |
{ | |
// code here.. | |
return View::make('import.index'); | |
} | |
public function post_wordpress() | |
{ | |
Input::upload('wp-file', 'storage/temp', 'wp_export.xml'); | |
$xml = simplexml_load_file('storage/temp/wp_export.xml'); | |
foreach ($xml->channel->item as $item) { | |
$namespaces = $item->getNameSpaces(true); | |
$xml_content = $item->children($namespaces['content']); | |
var_dump($item); | |
$post = new Post; | |
$post->title = $item->title; | |
$post->type = 'article'; | |
$post->date = date("Y-m-d H:i:s", strtotime($item->pubDate)); | |
$post->body = $xml_content->encoded; | |
var_dump($post); | |
$post->save(); | |
break; | |
} | |
// return Redirect::to('import'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment