0

This is essentially my first project with Craft and my plan is to take a personal photoblog and move it into Craft to learn how everything works before working with clients and craft.

I've got craft installed locally at testing.craft.dev and want to import my existing ExpressionEngine entries.

I've renamed the default "news section" to photography, added a new image upload asset and field to the layout. All of which I can see when Igo to Entries > Photography.

Now to import the entries I found Craft Import. I've installed this, created an xml file on my EE install.

<xml>
<blog>
{exp:channel:entries channel="photoblog" show_future_entries="yes" limit="500"}
<entry>
    <entry_date>{entry_date}</entry_date>
    <title>{title}</title>
    <slug>{url_title}</slug>
    <post><![CDATA[{description}]]></post>
    <images>
    {photos}
        {image}
    {/photos}
    </images>
</entry>
{/exp:channel:entries}
</blog>
</xml>

I've also set the url to this xml file on line 17 of services/craftservice.php. Where I'm stuck is that I now need to Update Lines 64-73 to match your Craft configuration and source nodes. Reference inline comments. Those lines are:

    // Find these in craft/app/models/EntryModel
    $entry->sectionId = $sectionId;
    $entry->typeId = $typeId; 
    $entry->authorId = 1; // 1 for Admin
    $entry->enabled = true;
    $entry->postDate = $importEntry->entry_date;
    $entry->slug = $importEntry->slug;
    $entry->getContent()->setAttributes(array(
        'title' => $importEntry->title,
        'post' => $post
    ));

Unfortunately I have no idea what I need to put in here. Any advice would be greatly appreciated.

As it stands if I try to load entry I get an error, no surprise there.

CDbCommand failed to execute the SQL statement: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'crafttest.craft_entries_i18n' doesn't exist

  • that example is based on a pre 2.0 version of Craft, so things have changed quite a bit. – Steven Grant Feb 16 '15 at 23:51
  • I dropped this plugin in favor of github.com/boboldehampsink/import which is working except it's not mapping images to the image field. – CreateSean Feb 17 '15 at 0:16
  • @CreateSean Hey Sean, can you post the steps you took as the official answer to your question? May help the next guy. – Brandon Kelly Feb 20 '15 at 0:55
  • @BrandonKelly Posted a new answer with full steps copied from a blog post I wrote about it. – CreateSean Feb 20 '15 at 15:52
2

As per Brandon's request in the comments to the original question here are the steps I used to import. Below is copied from a blog post I wrote with screenshots.

NOt sure why but my code bits are not displaying even though I've used the code button in the wysiwyg here. To see the full code bits go to my blog.

First use a different plugin https://github.com/boboldehampsink/import

  • copy all files from original site
  • in the Craft CP click the gear icon on the top right, then Assets, New source and fill in the fields. both the path and url can be set to relative paths, but be sure to not use a leading slash.
  • After saving click the gear icon again and go to the lower left and update asset indexes.
  • The next step is to install the Import plugin by putting the files in /craft/plugins then in the CP click gear and plugins and finally install.
  • This plugin only imports content in CSV format. This requires a new template in ExpressionEngine which will need to be set wiht php turned on in order to force the browser to download the file directly.

  • The next bit of code contains all our fields and how we want them named. This is important to easily map the fields using the import plugin. Line 20 has entry_date with extra spaces this is due to my blog rendering it and not displaying the code correctly - remove extra spaces for it to work. When migrating images, be sure to only include the image name. My images currently reside in a Matrix field {photos} and a file cell. In order to get just the file name it is necessary to use the file tag pair like this {image}{file_name}{/image} where the outer tag pair is the file field/cell name.

    Title Url Title Entry Date Description Image {exp:channel:entries channel='photoblog' limit='500' disable="categories|member_data|pagination|comments" status="not foo"} Migrating Content from ExpressionEngine to Craft {url_title} { entry_date } {description} {photos}{image}{file_name}{/image}{/photos} {/exp:channel:entries}

  • After downloading the file open it in Excel, you may see a warning that the file format doesn't match the extension, open it anyhow. Now do a save as and choose CSV (comma delimited). My research indicated that this extra step is necessary as using the template to save as CSV with content that contains quotes may not work correctly.

  • Now to import, click Import in the Nav. Fill in the fields as required and upload your CSV file.

  • Go to the next page where we map the fields to Craft fields.

  • 1
    Probably a little late, but another option (even just for the next person who comes across this) would be to use github.com/engram-design/FeedMe for importing, which is pretty similar to Import. Supports XML and very soon JSON. – crawf Mar 5 '15 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.