Using an alternate key for for importing F2C Articles with XML Import

The default F2C XML Import is default based on the Joomla generated Id of the F2C Article. Based on the Id, the articles will be updated, created or deleted. If you want to update your F2C Articles with data from an external system, the Joomla Ids are of no use; the external system should not have to know these Ids.

This tutorial will describe the use of an alternate key to use during the import, so that the internal Joomla Ids do not have to be used.

The default mechanism

The F2C XML Import can update existing F2C Articles during the import. This can be accomplished by setting the "Import Write Mode" in the Article Import/Export settings to "Update existing articles".
Initially, the import will look for the F2C Article to be updated, through the Id supplied in the XML import file. When it finds the article with the corresponding Id, the article will be updated. When the article is not found, a new article will be created.

The alternate key mechanism

Imagine that you want to update your Joomla website, which contains information about books, with information from an external (non-Joomla) system. You create an XML export from the external site, which complies with the F2C Import XSD, and use that file to import the book data into your Joomla website.
The alternate key mechanism provides a way to identifiy F2C Articles not using the internal Joomla ids, but by means of a self-defined alternate key. In the example with the books, the ISBN number would be a good candidate for an alternate key. Every book has an ISBN number that uniquely identifies the book.

How to implement the alternate key

The mechanism for the alternate key can be created like this: 
In the Content Type that defines the books add a new Single Line Text field called ISBN. Use this field to store the ISBN number for each book.

In the XML import file use the following syntax, instead of the default id syntax, to tell the import to use the ISBN field as the alternate key:


The value for the XML attribute fieldname should contain the fieldname to be used for the alternate key. The id value itself should now contain the value from the ISBN field, in this example: 978-1904811947.

F2C Cheat-sheet

An overview of all template parameters (placeholders for your form data). These are used in your F2C intro and main template to parse the data from your submission forms into the Joomla article.



Form2Content, a Joomla CCK Documentation © 2010 - 2015 Open Source Design | Powered by Form2Content