Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2017-04-07 12:09:18
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,304
export articles in xml
i’m not familiar with the topic at all.
so, client wants to export a bunch of real estate articles (text, images) in .xml into other site. is it possible and how difficult this is?
Offline
Re: export articles in xml
Not difficult. Once you know the format of the XML strcuture the external site requires, I would proceed as follows:
- Make a temporary, hidden Section in your site with a random name (like
export_to_xml
). - Make a Page template assigned to that Section.
- In your template, use
<txp:article_custom>
as a container and design your xml structure around it, placing txp:tags where you want the content injected, just like you would with HTML.
e.g.:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<records>
<txp:article_custom section="your-articles-section" limit="999" wraptag="record">
<title><txp:title /></title>
<content><txp:excerpt/> <txp:body /></content>
<photo><txp:article-image /></photo>
<number_of_rooms><txp:custom_field name="rooms" /></number_of_rooms>
...
</txp:article_custom>
</records>
Then just visit that Section of your site to view the XML document. Use ‘Save As’ to export it.
EDIT: you might have to export/download the images separately as they’ll only be URLs in the feed. Or find a way to embed them as BASE64 images or something.
Last edited by Bloke (2017-04-07 12:36:35)
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
Re: export articles in xml
What Stef said but you could use rah external so as to save you creating a new section
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Pages: 1