Jump to content
johnstephens

Importing content from Textpattern

Recommended Posts

I'd like to read up on importing content from Textpattern into a fresh ProcessWire installation. I know there are more than a few Textpatrons here: Is there a tutorial or thread or blog post covering this?

I've used Textpattern for years. I'm very familiar with it's database schema and pretty comfortable exporting and manipulating it with MySQL. ProcessWire's schema uses a totally different paradigm, and I'm not confident that I could simply dump the data and import it into ProcessWire with the same facility.

I'm happy with Textpattern for most of the sites in which I use it, but there are a few that I think using ProcessWire would be a significant boon.

Thanks in advance!

Share this post


Link to post
Share on other sites

You could always use an bootstrap script, which does connect to the Textpattern database, reads the data by mysql queries and then use the processwire api to fill those data into the pages you need.

  • Like 5

Share this post


Link to post
Share on other sites

Or you could build a module like MigratorWordpress: https://github.com/NicoKnoll/MigratorWordpress that gets the Textpattern content and creates JSON that can be imported into PW.

While it might be a little more work to build, it would be useful for other future users coming from TextPattern.

  • Like 4

Share this post


Link to post
Share on other sites

Hey johnstephens,

How large/complex is the Textpattern site? I moved a bunch of sites a few years back, and they were all pretty simple transfers. I didn't try to write any kind of importer, I was done with the transfers manually faster than I could write the importer.

  • Like 1

Share this post


Link to post
Share on other sites

Concepts like "bootstrap script" and writing my own importer were a bit much for me when I initially posted this question, but now that I'm facing a real need I might have to wrap my mind around them.

 

On 11/5/2015 at 8:53 AM, renobird said:

Hey johnstephens,

How large/complex is the Textpattern site? I moved a bunch of sites a few years back, and they were all pretty simple transfers. I didn't try to write any kind of importer, I was done with the transfers manually faster than I could write the importer.

At the time I wrote, I didn't have a specific site in mind to convert, but now I do. It's one of my more complex Textpattern sites, but it's not insane. Here's what I have:

- 7 major content "sections", some of which would be nested in a ProcessWire site. I also have some utility sections used for things like search and site map.
- 660 "articles", most of which belong to a knowledge base.
- 39 categories in two major divisions. Each article in the knowledge base belongs to two categories.
- The site uses Textpattern's MLP plugin/hack to offer content in two languages. The 660 article IDs include the renditions in both languages. On the front end, that means you can click on a language link for any article and view it's rendition in the other language. The URL changes from domain.tld/en/{section}/{url-title} domain.tld/es/{section}/{url-title}.
- The site uses 15 custom fields, with the glz_custom_fields plugin offering support for different field types. Articles in different sections use different combinations of the custom fields, but all the custom field data lives in the same table with the articles.

I think that covers all the complicating factors.

In a vanilla Textpattern installation, all the article content lives in one table, and I suppose importing it would involve some way of mapping the columns of that table to pages and fields in ProcessWire, with the "section" field designating the rootParent page. But this site has the added convolution of a localization table that maps articles in both languages so they can be linked appropriately.

Tom, when you say you transferred the content manually, do you mean you opened the article in Textpattern's editor (the Write tab) and simply copied and pasted each field to ProcessWire? Is that the method you'd recommend for this site, or is there some way of automating it that you'd suggest?

Thanks in advance for any guidance you can offer!

Share this post


Link to post
Share on other sites

Bootstrapping means 'require'-ing ProcessWire website from elsewhere, like this:

<?php
  require_once '/absolute/path/to/your/PW/site/index.php';

  foreach( \ProcessWire\wire('pages')->get('/')->children() as $ch ) {
    echo "{$ch->title}\n";
  }

I've just tried this so I won't lie to you: I literally just created this in in my home directory, ran it in terminal with PHP and got a list of page titles in the console.

So by writing your own importer, people mean something like this:

<?php require_once '/path/to/processwire/index.php'; 

$wire = \ProcessWire::wire();

// get stuff you want to import
$articlesToImport = \OldCMS\DB::query($oldSiteDB, 'select * from articles join whatever');

// iterate over it and create pages for it
foreach($articlesToImport->next() as $oldArticle){
	$newArticle = new \ProcessWire\Page();
	$newArticle->template = 'article';
	$newArticle->parent = $wire->get('/articles/');
	$newArticle->title = $oldArticle->get('title');
	$newArticle->body = $oldArticle->get('html');
	$newArticle->save();
}

And that's it. You've just imported some articles from your old CMS to your brand new ProcessWire installation.

Of course, on "real" pages you'll want to think about this for a bit; Maybe create pages for authors first, some categories, some tags, and then maybe add the pages in parts, so you don't timeout mid-import, or turn off timeout.

  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Rodd
      Hi everyone!
      I have a website in a production environment and I want to duplicate it in a local environment. I exported the content of the website (with the 'Site Profile Exporter' module) but I cannot use it actually. I've got an issue with the database. I imported this one in MAMP then.

      I also exported the pages (with the 'ProcessPagesExportImport' module), but I cannot import it to my local website because the fields don't exist. So I created this fields, but I have this error :
      How can I use the elements that already exist and are presents in my database? How can I duplicate correctly the templates, fields and pages?
      Thanks by advance
      PS: Sorry if my english is bad
       
    • By hellerdruck
      Hi all
      I need help with something. Situation: We have let's say 2'000 Files (Excel) that should be displayed (list with links) on a page. We'd need to filter these files by given Keywords or a tree structure or both. Now, I'm looking for a solution whereas our customer can synchronise the files from his local computer with the folder on the webserver. They will update and upload files on a daily basis. Therefore, it would need to synchronise rather than load the files manually in pages or repeaters. Maybe indexing would be an idea, too.
      Are there any modules for Processwire that would help achieving this? Could anyone point me in the right direction?
      Thanks in advance.
    • By iNoize
      Hello, need some help for an RealEstate project. It have to use the OnOffice to import the objects. 
      https://apidoc.onoffice.de/
       
    • By jds43
      Hello,
      Does anyone have experience with migrating content from Django to Processwire? Or are there any suggestions for achieving this?
    • By maba
      Hello,
      I need to import regularly - every 15 or 30 days - a big .xslx file into my PW installation.
      This file now has 14 columns, 5.000 rows and grows every month.
      I'll need to group, order and work with these data to:
      analyse User monthly costs analyse User costs per Asset ... User (real AD account) has to match with a PW user - I can't join to the domain - but as you can see I have some services users (start with sca_*) or no user at all. Those rows have to be assigned to a specific user, e.g. account100.
      And:
      I would like to be able to have a kind of diff function to compare User assets between this and last month (and so on) other request is to have a notification when something change for a User between actual and latest import First request: which is the best solution to store those data in your opinion? Page, Table, Repeater Matrix, ...?
      Those are very repetitive data and I think a page reference is better than to import all the data every time but I have to understand how to manage those "dynamic" groups of software (AccType Det), hardware (Asset), ... For example Price will be imported and not stored with the description because it could be change in the future and I'll not have any control on it.
      Thanks!
      User,OE,productNmr,AccType1,AccType Det,Count,Price (€),Sum,ASNA,CC,AccType Info,Asset,AccGroup,,,,,,,,,,,,,
×
×
  • Create New...