Skip to main content

Blog Manager by Echothemes doesnt have an official importer for blog posts from other platforms.

I wrote this code for my own use but I am sure it can be applied to most external blog systems as it works with the rss feed of a blog and makes use of the the functionality echothemes provides and vQmod.

I will try to explain everything as clearly as possible as far as I go, the code will be explained in the snippets below, just read the comments I placed in it, If you have questions just leave a comment I will reply when I have time, Keep in mind this doesnt pull in the authors, categories or the tags and it doesnt import photos, it ONLY pulls in the Date, Title, and Content of the post. It can be done but I dont have the need for it now. If you would like me to take this further drop me an email at janes{at}

Right, here we go.

Download the Package file form here. It includes everything you need ( 4 Files ).

Place the following code in a .xml file and place the file in the xml folder in the vQmod folder.

This file adds the import function to blog manager. It should be safe to update the plugin without and issues.


	<id>Blog Manager Import</id>
	<author>Janes Oosthuizen -</author>

        <file name="admin/view/template/blog/blog.tpl">
                <search position="after" offset="2"><![CDATA[<a href="<?php echo $this->url->link('blog/setting', 'token=' . $this->session->data['token'], 'SSL'); ?>">]]></search>
                    <a href="<?php echo $this->url->link('blog/article/importwordpress', 'token=' . $this->session->data['token'], 'SSL'); ?>">
                        <div class="iconHome"><img alt="" src="view/image/blog/icon_import.gif" /><br/><?php echo $text_import;?></div>

        <file name="admin/language/english/blog/blog.php">
                <search position="after" offset="0"><![CDATA[$_['text_setting']         = 'Settings';]]></search>
                    $_['text_import']         = 'Import';

        <file name="admin/controller/blog/article.php">
                <search position="before" offset="1"><![CDATA[private function validateForm() {]]></search>
                            public function importWordpress() {
                                // Load Language File
                                $this->data = $this->load->language('blog/import');

                                // Load Page Title

                                // Add Blog Manager Styling

                                //Load Models

                                // Set Breadcrumbs
                                $this->data['breadcrumbs'] = array();
                                $this->data['breadcrumbs'][] = array(
                                        'text'		=> $this->language->get('text_home'),
                                        'href'		=> $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
                                        'separator' => false
                                $this->data['breadcrumbs'][] = array(
                                        'text'		=> $this->language->get('heading_title'),
                                        'href'		=> $this->url->link('blog/blog', 'token=' . $this->session->data['token'], 'SSL'),
                                        'separator' => ' <span class="separator">&#187;</span> '
                                $this->data['breadcrumbs'][] = array(
                                        'text'		=> $this->language->get('head_article'),
                                        'href'		=> $this->url->link('blog/article', 'token=' . $this->session->data['token'], 'SSL'),
                                        'separator' => ' <span class="separator">&#187;</span> '

                                // If Form is submitted Start Import

                                     // Get Feed URl From Form
                                     $xml = simplexml_load_file($_POST['feed']);

                                     // Empty Variable to hold the results
                                     $datai = '';

                                     //Variable to count total posts imported
                                     $count = 0;

                                     // Loop through the Children of the feed
                                     foreach($xml->children() as $child) {

                                          // Loop through posts in the XML
                                          foreach($child->item as $ci){

                                              // Set Namespace to get the Post Content
                                              $postcontent = $ci->children('');

                                              // Prepare array for passing through to addArticle Function
                                              $datar = array();
                                              $datar['article_description'][1]['title'] = $ci->title;

                                              // Get the Content from the namespace tag
                                              $datar['article_description'][1]['description'] = $postcontent->encoded;

                                              $datar['status'] = $_POST['enable'];
                                              $datar['comment'] = $_POST['comment'];
                                              $datar['author_id'] = $_POST['author'];

                                              // Change date format to the correct one
                                              $datar['created'] = strftime("%Y-%m-%d %H:%M:%S", strtotime($ci->pubDate));
                                              $datar['modified'] = strftime("%Y-%m-%d %H:%M:%S", strtotime($ci->pubDate));

                                              // Set Default Store
                                              $datar['article_store'][] = 0;

                                              // Add Article into Database

                                              // Increment Count

                                      // Set Results Text
                                      $this->data['datai'] = "Total Posts Imported: ".$count;

                                // Get Text for Back Button
                                $this->data['menu_setting_href'] = $this->url->link('blog/setting', 'token=' . $this->session->data['token'], 'SSL');

                                // Get all the authors for the form
                                $this->data['authors'] = $this->model_blog_author->getAuthors();

                                // Set the Template
                                 $this->template = 'blog/import.tpl';
                                 $this->children = array(

                                 // Output the HTML


Next you can add the Template file (import.tpl) to the blog admin template folder ( admin/view/template/blog/import.tpl ).

This is just the basic template file containing the form and when submitted the results.

This Code contains the following:

<?php echo $header; ?>
<div id="content">
   <div class="breadcrumb">
      <?php foreach ($breadcrumbs as $breadcrumb) { ?>
         <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
      <?php } ?>

   <div class="container">
       <div id="et-header">
         <span class="em-header"><img src="view/image/blog/blog_manager.png" alt="<?php echo $heading_title; ?>" title="<?php echo $heading_title; ?>" /></span>
            <li><a href="<?php echo $menu_setting_href; ?>"><?php echo $text_menu_setting_back; ?></a></li>
       <div id="et-content">
          <form action="" method="post">
              <table class="form blogAbout">
                   <td><label><?php echo $feed_url; ?></label></td>
                   <td>: <input type="text" name="feed"/> <span style="color:#ccc;"><?php echo $feed_url_c; ?></span></td>
                   <td><label><?php echo $author; ?></label></td>
                   <td>: <select name="author">
                        foreach($authors as $a){
                            echo '<option value="'.$a['author_id'].'">'.$a['name'].'</option>';
                   <td><label><?php echo $enabled; ?></label></td>
                   <td>: <input type="text" name="enable"/></td>
                   <td><label><?php echo $comments; ?></label></td>
                   <td>: <input type="text" name="comment"/></td>
                   <td align="right"><input type="submit" class="button" value="<?php echo $submit_text; ?>"/></td>
                    <td colspan="2">
                        <?php echo $datai; ?>

<script type="text/javascript" src="view/javascript/blog/blog.js"></script>

<?php echo $footer; ?>

Then lastly:

Place the language file ( import.php ) in the admin language folder for the blog manager (admin/language/english/blog/import.php ).

This contains the text labels for the various elements.

Here is the code:

//== Heading
$_['heading_title']           = 'Blog Manager';
$_['head_import']              = 'Wordpress Importer';
$_['head_article']              = 'Wordpress Importer';

//== Menu
$_['text_menu_setting_back']       = 'Back to Settings';

$_['feed_url']      = 'Feed Url';
$_['feed_url_c']      = 'This is the url to your blog feed ex.';
$_['author']      = 'Author';
$_['enabled']      = 'Enabled';
$_['comments']      = 'Comments';
$_['submit_text']      = 'Import Posts';


That is Basically all there it to it. You should be able to drop the files in and start importing right away.

Update: The Status and Comments fields should have a value of 1 or 0. Forgot to put in dropdowns for them. 🙂

Just a note: I have developed this around the default feed that wordpress provides ( ). I have not tried this on other feeds. With a little changing this can be used on any feed I am sure. 

Also Before importing from wordpress, Make sure you have set the rss feed to show 9999 posts to get all posts in the feed and also make sure you have it set so the rss shows the whole post and not just a summary.

This was written in a hurry and like I said there is room for improvement.

Janes Oosthuizen

Author Janes Oosthuizen

Programmer and Tech Junky from Cape Town, South-Africa. I have been programming for more than 15 years in various languages including ( CSS, HTML, javascript, PHP, MySQL, Wordpress and many other ).

More posts by Janes Oosthuizen

Leave a Reply