I am working on preparing the way for an upgrade to 3.x and one of the issues I need to deal with is that I am currently using Playa and Matrix. As there’s no date for these add-ons being upgraded, I am looking at abandoning them for the native relationship field and grid. It has been suggested that I should use Datagrab for re-importing the data, and this seems like it will work. However, I am not sure how to get the data exported in the right format in the first place. I am also not sure I can replicate my current setup with the native solutions.
So, the first question is how I would go about doing the export? I have used the approach of setting up custom templates for exporting data in the past, but that has been straight-forward text fields.
The second question is what the equivalent template setup would look like for native relationships? Grid, from the look of it, is very similar to Matrix, so I think I have that one figured out.
My current use of Playa is to link TV-show episodes to characters in the episodes. For each episode, I add all characters that appear, and display them on the episode page like this:
{exp:channel:entries channel="{current_channel}"}
<ul>
{exp:playa:children field="{{current_channel_id}_characters}" orderby="title" sort="asc"}
<li><a href="http://{comment_url_title_auto_path}">{title}</a></li>
{/exp:playa:children}
</ul>
{/exp:channel:entries}
On each character’s page, I then display the episodes they appear in, like this:
{exp:channel:entries channel="{current_channel}"}
<ul>
{exp:playa:parents channel="channel38" orderby="38_id" sort="asc"}
<li><a href="http://{comment_url_title_auto_path}">{38_id}: {title}</a></li>
{/exp:playa:parents}
</ul>
{/exp:channel:entries}
If you use an XML template to create the export file for Datagrab you can add the relationships data something like this:
<root>
{exp:channel:entries channel="mychannel" limit="20" disable="pagination" orderby="entry_date" sort="desc" status="open" dynamic="no"}
<entry>
<count>{count}</count>
<title><![CDATA[{title}]]></title>
<urltitle>{url_title}</urltitle>
<entrydate>{entry_date format="%Y-%m-%d %H:%i:%s"}</entrydate>
<relationships>
{my_related_field}
<related_title>{title}</related_title>
{/my_related_field}
</relationship>
</entry>
{/exp:channel:entries}
</root>
That will output your relationship field like this:
<relationships>
<related_title>Something</related_title>
<related_title>Something else</related_title>
<related_title>Something else again</related_title>
</relationship>
Then in Datagrab when mapping your field for the import you’d map relationship/related_title to your new relationships field.
Matrix > Grid is similar.
In your export template add code to get your matrix data :
<matrix>
{my_matrix_field}
<matrix_item>
<image>{matrix_image_field}</image>
<text1><![CDATA[{matrix_text1_field}]]></text1>
<text2><![CDATA[{matrix_text2_field}]]></text2>
</matrix_item>
{/my_matrix_field}
</matrix>
…where {matrix_image_field} is the full URL of the image (you can get datagrab to pull the image file across during import) and the matrix_item field repeats according to the number of rows you have. For the image you can also upload them manually and use https://ellislab.com/asset/images/team-photo/imagename.png.
When you do the import you map each matrix data column into Datagrab, see http://brandnewbox.co.uk/support/details/datagrab_and_matrix_fields for examples.
I’ve finally gotten a chance to test this out. I’ve got the export for the Playa data working fine (I think), though I seem to be running into some issues with the import into a Relationship field. It asks for an ID, and while ID is a required field for this channel, it is supposed to be importing into existing entries, not creating new ones.
I am also having issues with exporting the Matrix data. This is the current result: http://hippoiathanatoi.com/Virtually/Otherworldly/Export
I am guessing the issue is that the text fields I am trying to import can contain html and that this is causing a problem?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.