Skip to content

Instantly share code, notes, and snippets.

@bsag
Created January 4, 2012 10:34
Show Gist options
  • Save bsag/1559490 to your computer and use it in GitHub Desktop.
Save bsag/1559490 to your computer and use it in GitHub Desktop.
Create a WXR-format export file to export comments from ExpressionEngine and import into Disqus
I had some difficulty trying to get a format exported from ExpressionEngine which I could use to import comments into Disqus, and eventually settled on the code above after looking at Disqus' own import format (http://docs.disqus.com/developers/export/import_format/) and trawling the ExpressionEngine forums to adapt other solutions which exported to Movable Type format.
You need to start off by creating a new template group called 'export'. Inside that, you make a template called 'index' and paste in the contents of index.xml above, making sure that you replace the channel name and template group name to those appropriate for your setup. This needs to be the index for the template group. Next, create another template called 'comments' and paste the contents of comments.xml, again, replacing the channel name as appropriate.
Now visit http://yoururl.com/export and you should see the exported entries. Wait for the whole page to load which may take some time with a lot of entries. Then use your browsers 'View source' command to view the source of the page, copy all the text and paste into a text file with the extension '.xml'. Now you should be able to upload to Disqus using their 'Generic (WXR)' importer.
You may find that you encounter errors and have to try uploading several times. For example, you need to make sure that the xml declaration is the very first line of the file (the template will insert some whitespace.
Good luck!
{exp:comment:entries channel="MY_CHANNEL_NAME entry_id="{embed:the_entry_id}" sort="asc"}
<wp:comment>
<wp:comment_id>{comment_id}</wp:comment_id>
<wp:comment_author><![CDATA[{name}]]></wp:comment_author>
<wp:comment_author_email>{email}</wp:comment_author_email>
<wp:comment_author_url>{url}</wp:comment_author_url>
<wp:comment_date_gmt>{comment_date format="%Y-%m-%d %H:%I:%S"}</wp:comment_date_gmt>
<wp:comment_content><![CDATA[{comment}]]></wp:comment_content>
<wp:comment_approved>1</wp:comment_approved>
<wp:comment_type></wp:comment_type>
<wp:comment_parent>0</wp:comment_parent>
</wp:comment>
{/exp:comment:entries}
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dsq="http://www.disqus.com/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.0/"
>
<channel>
{exp:channel:entries channel="MY_CHANNEL_NAME" limit="999" rdf="off"}
<item>
<title>{title}</title>
<link>{title_permalink=MY_TEMPLATE_GROUP/comments}</link>
<content:encoded><![CDATA[{body}{extended}]]></content:encoded>
<dsq:thread_identifier>{url_title}</dsq:thread_identifier>
<pubDate>{entry_date format='%D %d %M %Y %H:%I:%s %Q'}</pubDate>
<wp:post_date_gmt>{entry_date format='%Y-%m-%d %H:%I:%s'}</wp:post_date_gmt>
<wp:comment_status>open</wp:comment_status>
{embed="export/comments" the_entry_id="{entry_id}"}
</item>
{/exp:channel:entries}
</channel>
</rss>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment