Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2017-02-25 09:53:58

Bongo-man
Member
Registered: 2009-03-18
Posts: 243

Any way to download all the articles from the database in'doc' format?

Is there any way to get a backup of all the articles in the database, downloading them in ‘doc’ format, with each field (title, article, keywords, description, and so on) in a different line?

Offline

#2 2017-02-25 11:31:07

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,925
Website GitHub

Re: Any way to download all the articles from the database in'doc' format?

I know of no direct way, but if you’re not afraid of some manual work, there are some alternatives.

For small sites it may be simplest to either:

  • copy and paste manually, or
  • create an output template with the output you need as a very simple HTML page, save those pages in the browser as source code and open them in Word, resaving them as Word documents one by one.

For large sites, where this may not be feasible, I can think of two ways off hand:

1: Database -> Export to CSV -> Mailmerge to Word

  • Export your required database table as a CSV file. You can do that from phpmyadmin or other tools.
  • Create a Word mailmerge document that reads in the relevant fields from the CSV file.
  • Do your mailmerge.

You may have to massage your CSV file a bit, depending on your locale, export separators, field quoting etc. I think you’ll also end up with a long word document containing all articles, unless word offers a way of saving each mail merge as a separate document. I’ve forgotten whether that’s possible.

2: Output template as textile -> Split into separate docs in terminal -> Use Pandoc in Terminal to convert textile to Word

I’ve used this in the past to retrieve data from a large database with profiles that needed sending out individual for updating manually as Word files. I’ll outline only the process for now but can provide details if you think it at all feasible:

  • Create an output section and define a template for outputting the article information on separate lines etc. Format the template output as textile rather than HTML. Include a unique character string between each article (you’ll use this later to split your document). I also output the section_article-url-title here to use as the file name.
  • Call up your output section in the browser, then display the source and copy that out into one long text document with all the articles one after the other. The main thing is you want the page source, not what the browser renders.
  • Use a small bash script in the terminal (I have one for the Mac but not to hand while writing this) that splits the long document into one file per article, naming the file according to the naming scheme. It takes a few seconds and you end up with a folder full of textile-format documents named section_article-url-title.textile.
  • Use pandoc (also a command-line tool) to convert the folder full of individual textile documents into individual word documents. Again, it takes just seconds. The Word files will be very basic and generally use the default Word formatting in your normal.dot word template, but they are at least usable for others.

Getting the information back into textpattern again is another matter. If you need a round-trip process, you might be better off bypassing word and developing an online edit panel for allowing people to update their entries online.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2017-02-26 08:09:43

Bongo-man
Member
Registered: 2009-03-18
Posts: 243

Re: Any way to download all the articles from the database in'doc' format?

Thank you for the answer; it’s a little complicated, but I will try ASAP.

Offline

Board footer

Powered by FluxBB