Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2014-11-11 14:39:34

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: Assistance With Import

Bloke/Dragondz:

A couple of additional items that have come up that I would appreciate guidance on —
  1. All my articles have images attached to them —- I had originally thought that I could just move the images into another folder and then reset the path — what I have noticed now is that the TXP Table references the image number from the TXP Image Table — the TXP Image table does not show a path (I assume because it thinks there is only the one default path) — how do you feel it would be best to address this item — ie do I create a new custom field to store that information inside the article table or is there some other method maybe more refined?
  2. My articles all use custom fields (and a lot of them). I see know other way around it — but prior to import map DB2 to the new DB1 custom_fields — also is there a limit on the number of custom fields that can be created —- I use Gerhard’s plug in —-
  3. Bloke had mentioned TXP would auto assign numbers — can I get a bit more clarification —-

I am now waffling on “best import method” and I am hoping the above questions will lead me down the proper road —-

progre55

Last edited by progre55 (2014-11-11 14:41:16)

Offline

#14 2014-11-11 16:13:18

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: Assistance With Import

progre55 wrote #285673:

All my articles have images attached to them

The txp_image table holds the IDs of the pictures that appears as physical files with the same ID in the image folder (Advanced preference). If you’re importing articles that have IDs you need to be aware of any clashes with existing images IDs and renumber accordingly.

There isn’t really a nice way round this. The best way might be to do something jakob touched upon: figure out how many images you have already in your destination Txp, and use a batch script to alter all the image IDs in the database and filenames in the /images folder to a higher value. So, if you had 268 images already, use a script to add a fixed value to your existing image IDs, say, ‘300’. viz:

  • 1 => 301
  • 2 => 302
  • 10 => 310
  • 16 => 316
  • 135 => 435

Updating the txp_image table is easy in one (untested) line on the DB you want to import:

UPDATE txp_image SET id = id + 300;

But updating the images in the article_image field of each article to match is somewhat more tricky. You’d probably need to make a note of the new number in the script above in a MySQL variable and use that to run a second query for each image to search the article image field and alter any values it finds. This will be made more complicated if you are using lists of images in the article_image field. That’s all beyond my current SQL knowledge (though I could do it in PHP), but someone else (or the Internet) might be able to assist.

The final step is to use a batch filename editor (if you’re on Windows, BRU is indispensable for this kind of thing) to alter the image IDs in your folder to match, then upload them, and import your database.

There’s no limit on custom fields in Gerhard’s plugin, as long as your host has enough space for the MySQL database itself.

Regarding automatic ID assignment, if you were to edit all rows of your exported dataset to remove the ‘ID’ column, Txp would automatically assign a new ID starting from the “most recent” one it last created. So if your export was a bit like this:

INSERT INTO `textpattern` (`ID`, `Posted`, `Expires`, `AuthorID`, `LastMod`, `LastM...
(1, '2009-03-02 00:05:28', '0000-00-00 00:00:00', 'bloke', '2014-09-30 10:02:55', '...
(291, '2013-09-26 23:08:29', '0000-00-00 00:00:00', 'bloke', '2013-09-26 23:08:29',...
(2, '2009-03-03 15:31:11', '0000-00-00 00:00:00', 'bloke', '2014-07-25 09:13:20', '...

lop off the `ID` column identifier and all the data in the first column so it looks like this:

INSERT INTO `textpattern` (`Posted`, `Expires`, `AuthorID`, `LastMod`, `LastM...
('2009-03-02 00:05:28', '0000-00-00 00:00:00', 'bloke', '2014-09-30 10:02:55', '...
('2013-09-26 23:08:29', '0000-00-00 00:00:00', 'bloke', '2013-09-26 23:08:29',...
('2009-03-03 15:31:11', '0000-00-00 00:00:00', 'bloke', '2014-07-25 09:13:20', '...

If you had 268 article in your existing database, when you import that amended file, Txp will start auto-numbering your articles from 269(ish: depends if you have deleted any articles after the last one in the database).

The only thing you have to watch here is that you don’t have any hard-coded references to article IDs in your Forms or other posts, as they’d all need updating as well to reflect the new ID values.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#15 2014-11-12 16:14:19

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: Assistance With Import

Bloke:

Thank you for your detailed response — you rock —- not the answer on the images that I was looking for — but it is what it is —-

When you state remove the ID column from the export of DB2 — and then import into DB1 — are you suggesting importing using the Textpattern import capability [Movable Type (File) Movable Type (MySQL DB) ] or importing using phpmySQL —

progre55

Offline

#16 2014-11-12 16:32:17

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: Assistance With Import

progre55 wrote #285695:

importing using phpmySQL

^^ this.

You need to export the data from one phpMyAdmin, edit the file it spits out to remove the ID column and then import it into the other database via phpMyAdmin again.

I’ve never used the Txp import facility but assumed since your existing DB was already Textpattermn you wouldn’t be doing that since it doesn’t support Txp -> Txp imports.

Note to self: why the hell don’t we have a facility to import data from another Textpattern installation on the Admin->Import panel?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#17 2014-11-12 16:53:20

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

Re: Assistance With Import

Bloke wrote #285696:

Note to self: why the hell don’t we have a facility to import data from another Textpattern installation on the Admin->Import panel?

It’s hacky, but I’ve done this before:

  1. Use this to make a Wordpress backup.
  2. Use the Wordpress import tool.
  3. Feel a bit dirty.
  4. ?
  5. Profit.

Last edited by gaekwad (2014-11-12 16:53:34)

Offline

Board footer

Powered by FluxBB