1 of 2
1
Import Textpattern into EE
Posted: 17 May 2007 04:35 PM   [ Ignore ]  
Summer Student
Total Posts:  12
Joined  08-20-2005

I think I’ve come with a new way to import Textpattern entries into EE. It’s worked for me, and I wondered if anyone else fancied testing it? I’v tried a script that was mentioned on the wiki, but it generated errors when trying to create dates (which meant that all dates were 1970!). Also, I have several sections that need to be translated to separate weblogs in EE.

The approach is to use Textpattern’s templates system to output the entries in a movabletype format.

- Create a new section called ‘export’ and link it to a new page template called ‘export’. In that template add the following:

<txp:article_custom section="name-of-txp-section-here" form="export" limit="4" />

- Then create an article form called “export” with the following:

TITLE: <txp:title />
AUTHOR: <txp:author />
DATE: <txp:posted format="%m/%d/%G %I:%M:%S %p" />
PRIMARY CATEGORY: <txp:category1 />
CATEGORY: <txp:category2 />
<
txp:php>echo "-----"."\n";</txp:php>
BODY:
<
txp:body />
<
txp:php>echo "-----"."\n";</txp:php>
<
txp:if_excerpt>
EXCERPT:<txp:excerpt /></txp:if_excerpt>
<
txp:php>echo "-----"."\n";</txp:php>    
<
txp:if_comments>
<
txp:comments form="exportcomments" break="" />
</
txp:if_comments>
<
txp:php>echo "--------"."\n";</txp:php>

- Then create a comment form called ‘exportcomments’ with the following:

COMMENT:
AUTHOR: <txp:comment_name link="0" />
EMAIL: <txp:comment_email />
URL: <txp:comment_web />
DATE: <txp:posted format="%m/%d/%G %I:%M:%S %p" />
<
txp:comment_message />
-----

- The visit yourdomain.com/export and view the source. Copy and paste this into a .txt file, and import into EE making sure to select formatting to none (the entries are already in HTML).

That seemed to do the trick for me, but if anyone else fancies a go on a test site to see if it does work, then great!

Edited to make the date output correctly

Profile
 
 
Posted: 17 May 2007 04:51 PM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  30659
Joined  05-14-2004

That was what I did when I moved from txp in 2004.  I haven’t had any problems in the years since.. =)

Thank you for posting it! I hope you’ll consider wiki’ing the solution, too.  The wiki didn’t exist back then so it’s not in there, hehe.

 Signature 
Profile
 
 
Posted: 17 May 2007 05:11 PM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  443
Joined  10-14-2005
Jon Hicks - 17 May 2007 04:35 PM

I wondered if anyone else fancied testing it?

For sure… I’ve been putting it off for ever but this sounds like it’s a winner.

 Signature 

Nathan Pitman

Nine Four Ltd - a member of the EEPro Network

Profile
 
 
Posted: 17 May 2007 06:04 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  443
Joined  10-14-2005

Well… it kinda worked, in admin I can see my entries, but for some obscure reason they’re not turning up on the public site… it’s late though so that could be user error. smile

http://ee.nathanpitman.com

 Signature 

Nathan Pitman

Nine Four Ltd - a member of the EEPro Network

Profile
 
 
Posted: 17 May 2007 06:18 PM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  443
Joined  10-14-2005

Hmm, ok so on further investigation I’ve discovered a more immediate problem which is that comments are not importing correctly.

This is most likely because my TXP export script isn’t honouring the <txp:comment_name link="0"/>. So I have comment output which includes links where I should just have a plain text commentor names.

http://nathanpitman.com/export/

I’m running TXP 4.0, what v are you running Jon?

 Signature 

Nathan Pitman

Nine Four Ltd - a member of the EEPro Network

Profile
 
 
Posted: 17 May 2007 06:30 PM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  443
Joined  10-14-2005

Ok, I found a fix for the comment name appearing as a link. This is more of a workaround but hey, who cares…

Download and install the ’glx_thiscomment‘ plug-in for TXP and replace the ‘exportcomments’ form with the following:

COMMENT:
AUTHOR: <txp:glx_thiscomment key="name" />
EMAIL: <txp:comment_email />
URL: <txp:comment_web />
DATE: <txp:comment_time format="%d/%m/%G %I:%M:%S %p" />
<
txp:comment_message />
-----

Run your export script again and then re-import your data back into EE using the MT import utility.

 Signature 

Nathan Pitman

Nine Four Ltd - a member of the EEPro Network

Profile
 
 
Posted: 17 May 2007 06:34 PM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  443
Joined  10-14-2005

Right, well I’m off to bed now, the comment import was improved that time around but still not what I was expecting. The import script seems to only maintain the author details for the latest comment against each article and then dump all of the comments in under that one comment entry. :? Need sleep!

 Signature 

Nathan Pitman

Nine Four Ltd - a member of the EEPro Network

Profile
 
 
Posted: 18 May 2007 01:14 AM   [ Ignore ]   [ # 7 ]  
Summer Student
Total Posts:  12
Joined  08-20-2005

Thats strange Nathan - it worked for me, but I’m using TXP 4.04. The link attribute in this bit:

<txp:comment_name link="0" />

Is to output just the name, and not a link. Are you only on v4.0? I’m pretty sure this was a recent addition.

Profile
 
 
Posted: 18 May 2007 04:09 AM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  443
Joined  10-14-2005

Yea I suspected that I might to upgrade my TXP install but couldn’t be faffed with that. How did you get on RE the comment import?

 Signature 

Nathan Pitman

Nine Four Ltd - a member of the EEPro Network

Profile
 
 
Posted: 18 May 2007 06:35 AM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  12
Joined  08-20-2005

It all worked well. I’ll send you a URL off list for proof!

Sounds like you need a more recent install of TXP before doing this though. I’m surprised you haven’t update - even though they are small point releases, it delivers more tags and conditional tag flexibility.

Profile
 
 
Posted: 18 May 2007 06:58 AM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  443
Joined  10-14-2005

Ok, I’ve just seen your proof and I’m well impressed. I’ll try a TXP upgrade…

 Signature 

Nathan Pitman

Nine Four Ltd - a member of the EEPro Network

Profile
 
 
Posted: 20 May 2007 01:48 AM   [ Ignore ]   [ # 11 ]  
Summer Student
Total Posts:  12
Joined  08-20-2005

Oddly some of my entries got the wrong date. I imported 4 as a test, and the oldest 2 were imported correctly, but the latest 2 obtained dates that were next year! Ill need to look into this.

Profile
 
 
Posted: 20 May 2007 02:16 AM   [ Ignore ]   [ # 12 ]  
Summer Student
Total Posts:  12
Joined  08-20-2005

Ah! Sorted it! The date needs to output from TXP in US format - Month/Day/Year. So the textpattern line in the export form and exportcomments form needs to be:

<txp:posted format="%m/%d/%G %I:%M:%S %p" />

Then it’s imported correctly! :D

I’ve changed this in the original post code

Profile
 
 
Posted: 21 May 2007 01:22 AM   [ Ignore ]   [ # 13 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  443
Joined  10-14-2005

I haven’t had a chance to finish the update to my TXP install yet, hoping to find time to try that today and then I’ll report back on what results I get. smile

 Signature 

Nathan Pitman

Nine Four Ltd - a member of the EEPro Network

Profile
 
 
Posted: 21 May 2007 07:19 AM   [ Ignore ]   [ # 14 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  443
Joined  10-14-2005

Ok, I ran the update script to upgrade from TXP 4.0 to 4.04 but that seemed to do absolutely nothing contrary to what was suggested on the TXP website. Anywhoo I ran back through the TXP forms to make sure there was no extraneous white space (which there was) so I removed this and tried again (incorporating you recent tweak RE US date formats) and it all seemed to work fine!

I seem to end up with 1 empty category in my categories group but I’ll just delete this. I haven’t attempted to import any drafts or such like yet so I can’t comment on whether they are preserved, did you try that yet Jon?

Oh, and one other thing I would like to try is to find a way to import the body and summary text as textile rather than rendered out as HTML, but at the end of the day it all depends on how precious I am over my previous entries, I can always use the EE Textile Plug-in for future entries. smile

 Signature 

Nathan Pitman

Nine Four Ltd - a member of the EEPro Network

Profile
 
 
Posted: 21 May 2007 07:58 AM   [ Ignore ]   [ # 15 ]  
Summer Student
Total Posts:  12
Joined  08-20-2005
nathan - ninefour - 21 May 2007 07:19 AM

I can always use the EE Textile Plug-in for future entries. smile

Thats what I was hoping I’b be able to do. Keep the older entries as HTML, but all new posts be using the Textile plugin. I’m assuming that would work, haven’t tried it yet though.

Haven’t attempted drafts yet, but *think* there are some new TXP attributes that allow those to be output in some way. I’m tempted to just forget those and start afresh anyway!

Profile
 
 
Posted: 21 May 2007 01:41 PM   [ Ignore ]   [ # 16 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  443
Joined  10-14-2005

Well, after a little searching I’ve found a better solution, one which will allow you to maintain all the textile from your historical TXP entries. You’ll need to install a plug-in called ‘msv_show_article_field’ (http://www.svihla.net/textpattern_plugins/) which is written by Martin Švihla. This plug-in allows you to return values from any of the article DB columns, so instead of returning the ‘body_html’ field which contains the HTML equivalent of your Textile markup, you can return the Textile itself from the ‘body’ field and likewise for the excerpt.

Replace the code for your export form with the following:

TITLE: <txp:title />
AUTHOR: <txp:author />
DATE: <txp:posted format="%m/%d/%G %I:%M:%S %p" />
PRIMARY CATEGORY: <txp:category1 />
CATEGORY: <txp:category2 />
<
txp:php>echo "-----"."\n";</txp:php>
BODY:
<
txp:msv_show_article_field name="Body" />
<
txp:php>echo "-----"."\n";</txp:php>
<
txp:if_excerpt>
EXCERPT:<txp:msv_show_article_field name="Excerpt" /></txp:if_excerpt>
<
txp:php>echo "-----"."\n";</txp:php>  
<
txp:if_comments>
<
txp:comments form="exportcomments" break="" />
</
txp:if_comments>
<
txp:php>echo "--------"."\n";</txp:php>

smile

 Signature 

Nathan Pitman

Nine Four Ltd - a member of the EEPro Network

Profile
 
 
Posted: 21 May 2007 01:48 PM   [ Ignore ]   [ # 17 ]  
Summer Student
Total Posts:  12
Joined  08-20-2005

Superb, what a find! I’ll have to give this a go when I get a chance! The EE trial will have to wait until after @media now…

Profile
 
 
Posted: 21 May 2007 01:52 PM   [ Ignore ]   [ # 18 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  443
Joined  10-14-2005
Jon Hicks - 21 May 2007 07:58 AM

Haven’t attempted drafts yet, but *think* there are some new TXP attributes that allow those to be output in some way. I’m tempted to just forget those and start afresh anyway!

Likewise, I think I will ditch all of my drafts. Though you could split the export from TXP into one script for live articles and one for draft articles. smile

 Signature 

Nathan Pitman

Nine Four Ltd - a member of the EEPro Network

Profile
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 10:33 AM
Total Registered Members: 59683 Total Logged-in Users: 30
Total Topics: 71215 Total Anonymous Users: 19
Total Replies: 383823 Total Guests: 484
Total Posts: 455038    
Members ( View Memberlist )