unanswered question

How to export and import Book nodes?

I wanted to move a Book from one site to another. I see a couple of modules that look up to the task – Book Import and Export DocBook – but they're for 4.x only. For 5.x, I see Export DXML. Yet the scant description online (http://drupal.org/project/export_dxml) says that Book Import (the 4.x module) is used to then import the exported content. Hmm.

Question answer

This plea of mine on the Drupal.org forums got no response but the dolorous sigh of a forsaken wind. Just as I was about to retreat to bitter existence's sole comforting shoulder – I'll always be there for you too, Wild Turkey – the kindly and knowledgeable GR stepped in by email with ideas.

I headed to phpMyAdmin (which used to scare me but I'm better now, thank you), called up my donor database that held the Book captive, and used this SQL command:

select * from 'node' where type='book' 

which selects all records from the node table, of type 'book'. I exported the results into a file.

Then I went to the hot-with-anticipation recipient database and attempted to import the file. The returned message started as follows:

INSERT INTO `node` ( `nid` , `vid` , `type` , `title` , `uid` ,
`status` , `created` , `changed` , `comment` , `promote` ,
`moderate` , `sticky` )
VALUES ( 13, 13, 'book', 'Understanding These Instructions', 1, 1,
1168408293, 1188227828, 2, 0, 0, 0 ) ,...

... and so on, for 40 or so book records within VALUES. But it then all failed with the error:

#1062 - Duplicate entry '13-13' for key 1

Apparently, the first record, which has nid (node ID) 13 and vid (version ID) 13, ran up against an existing node that also has nid 13 and vid 13. Like two Jean-Claude Van Dammes in Timecop, these cannot exist in the same place at the same time without results most distressing.

Interestingly, the clash didn't involve any existing Book nodes, as the site in question (this one!) had no Book nodes. So the existing node fervently laying claim to nid/vid 13 wasn't a Book node, but apparently that makes no difference.

I figured that I needed some way to change the nid/vid numbers of the old Book nodes before exporting them. Back to the donor site's database. GR helped out with the SQL here:

update node_revisions set nid=nid + 1000000 where nid in (select nid from node where type='book');

then

update node set nid=nid + 1000000 where type='book' 

(I like the audacity of the numbers! Works for me: if we're going to artificially boost the ID numbers, let's kick the buggers up into the bloody ionosphere.)

That done, I went and did the same for vid too (replace nid with vid in the above). And once again,

select * from 'node' where type='book' 

and export.

GR reminded me that I need to export and import not just from the nodes table, but from the node_revision table as well. So I did the same updating of nid/vid within that table, then the export procedure, all replacing node with node_revision.

Next up: you guessed it, head to the recipient database and import my files containing the above exports.

Solved?

Alas... things weren't quite licked. The nodes didn't function properly as Book nodes. They showed up as content, but the imported Book structure didn't show up in any way under admin/content/book. And when editing or creating a Book node, none of my imported Book nodes showed up under the drop-down Parent field – i.e., there wasn't a way to recreate the actual structure of the book. The nodes were there, but they weren't right. ("The nodes are sour", a crusty Maine character might deliver in a Stephen King yarn.)

Well, around there I cheated, and brought over my Book the really old-fashioned way: cut'n'paste from the donor site into fresh new Book nodes on the recipient site. (Those are, by the way, the Easy Drupal Admin Manual.) I had a lot of editing in store for each node anyway, so a one-step mass import wasn't an utmost requirement. Still, a chagrined Ace I am.

Sleuthster GR suggests that I left a third vital table out of the process: the books table, which also needs its nids/vids changed, and its content exported and imported, like the other tables above. Hmm, a table called books... that does sound suspiciously important to the task at hand. Chagrined and red-cheeked I am.

That extra step may have done the deed, but I had already embarked upon my more Luddite methods, and since then have not had cause to attempt a fresh export and import of a Book. So I'm going to leave this one an Unanswered Question for now, simply because I can't yet verify the whole proper process. But I hope this tale, and GR's assistance, will help someone else complete the task. Please write in if you have experience or ideas here!

Another method?

The helpful boris-doesborg suggests here that two modules that may provide a solution:

http://drupal.org/project/importexportapi
and
http://drupal.org/project/node_import

I don't have need or opportunity to experiment with these now, but if anyone out there does, please report!

Read morenode/173Read the rest of this posting.

What are general methods to enable fields for input by visitors?

Drupal's many node types are great for making all kinds of content, and CCK multiplies the possibilities many times over.

One thing I can't quite grasp, though: Is there some general, built-in method for enabling individual fields that allow visitors to input data?

To clarify that, let me first note what I'm not talking about:

Read morenode/63Read the rest of this posting.

How to display message (NDA, warning, etc.) before content can be viewed?

Say a user wishes to view a certain piece of sensitive content. How can we have the site first respond with a notice, before the content can be viewed?

Specifically, I'm looking to have the site respond with a simple NDA (Non-Disclosure Agreement) before displaying certain nodes (and even then, only to registered users, of course). But I can imagine many more uses: displaying conditions and terms related to the content, displaying an age warning for... er, more delicate content, and so on.

Read morenode/62Read the rest of this posting.

How to change page layout for newbie vs superfan visitors?

I recently read this article on distinguishing between one-time visitor "noobs" vs regular visitor "superfans", to dish up a different page to each.

Read morenode/57Read the rest of this posting.

How to handle bullet indentation in Garland theme's style.css?

From a CSS amateur:

I have text showing in nodes and in added blocks that makes use of bullets. Especially in blocks, width is limited; I'd like the bullet items lined up all the way to the left, to prevent lines breaking. But Garland gives me some serious bullet indentation.

Scanning style.css, I can't find the appropriate control. I chased down some ideas in CSS resources, and added this to the beginning of style.css:

ul {
list-style-type: none;
margin-left:0px;
padding-left: 0px;
}

Read morenode/56Read the rest of this posting.

Can user choose from multiple TinyMCE multiple profiles?

With the latest TinyMCE, I finally have pre-5.x TinyMCE functionality restored to my 5.x sites. Where can I send new Porsches to the people responsible? : >

But first, simple questions:

TinyMCE allows setting up profiles. This is great so that top admins can have an advanced profile chock full of buttons, and anon users can have a simple profile with just buttons for the basics (bold, italic, etc.).

Read morenode/55Read the rest of this posting.

Why bizarrely wrong node dates in Recent Block?

Does anyone know why node dates in a Recent Blocks list would come out wrong? I mean bizarrely wrong: they all come up "36 years 35 weeks ago". They're actually several days old...

Read morenode/53Read the rest of this posting.

Syndicate content