<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Marcus Povey &#187; import</title>
	<atom:link href="http://www.marcus-povey.co.uk/tag/import/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.marcus-povey.co.uk</link>
	<description>Making the world a better place, one byte at a time...</description>
	<lastBuildDate>Mon, 06 Feb 2012 19:13:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
	<atom:link rel='hub' href='http://www.marcus-povey.co.uk/?pushpress=hub'/>
		<item>
		<title>Import and Export in Elgg 1.0</title>
		<link>http://www.marcus-povey.co.uk/2008/07/31/import-and-export-in-elgg-10-2/</link>
		<comments>http://www.marcus-povey.co.uk/2008/07/31/import-and-export-in-elgg-10-2/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 17:13:44 +0000</pubDate>
		<dc:creator>Marcus Povey</dc:creator>
				<category><![CDATA[elgg]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://www.marcus-povey.co.uk/?p=56</guid>
		<description><![CDATA[Perhaps one of the most useful and unique features about Elgg 1.0 is its ability to import and export data. Initially this is accomplished via OpenDD, but we have added hooks which make it very easy to add other formats. I&#8217;m going to talk a little bit about how this works. Firstly, Export. Export works [...]]]></description>
			<content:encoded><![CDATA[<p>Perhaps one of the most useful and unique features about Elgg 1.0 is its ability to import and export data. Initially this is accomplished via OpenDD, but we have added hooks which make it very easy to add other formats.</p>
<p>I&#8217;m going to talk a little bit about how this works. Firstly, Export.</p>
<p>Export works via the <a href="http://docs.elgg.org/wiki/Views">views system</a>, and involves creating a brand new view hierarchy for your new format.</p>
<p>We first need to <a href="http://docs.elgg.org/wiki/Tutorials">create a plugin</a>, and in this plugin we create a &#8220;views&#8221; directory. We need to then create a new directory for your format, and then create a couple of views underneath.</p>
<p><img class="alignleft" style="float: left;"src="http://www.marcus-povey.co.uk/wp-content/viewsactions.png" alt="" width="216" height="330" />The image to the left shows the necessary file hierarchy that you need to create &#8211; in this instance to export &#8220;myformat&#8221;.</p>
<p>Create a directory called &#8220;export&#8221;. In this directory place the three php files &#8211; <code>entity.php</code>, <code>metadata.php</code> and <code>relationship.php</code> &#8211; which handle entities, metadata (and annotations) and relationships respectively.</p>
<p>Each of these files are passed objects via <code>$vars</code>. Depending on which file you are in, this might be <code>$vars['entity']</code>, <code>$vars['metadata']</code> or <code>$vars['relationship']</code>.</p>
<p>It is then up to you to encode and output the object according to your format.</p>
<p>All that remains is to provide the <code>pageshell</code> which handles how the overall page is displayed. This file may set the content-type header or provide wrapping tags (e.g. for XML output).</p>
<p><code>pageshell.php</code> is passed <code>$vars['body']</code> containing the output of your other files.</p>
<p>Providing a handler to deal with importing data is also fairly simple, and works through the <a href="http://docs.elgg.org/wiki/Actions">action interface</a>.</p>
<p>In your plugin&#8217;s init function register the action &#8220;import/YOURFORMAT&#8221;, and point it to your <code>actions/import/myformat.php</code>, e.g.</p>
<blockquote>
<pre>&lt;?php

	function myformatplugin_init()
	{
		global $CONFIG;

		// Register import action
		register_action('import/myformat', false,
		  $CONFIG-&gt;pluginspath . "myformatplugin_init/actions/import/myformat.php");
	}

	// Initialise
	register_elgg_event_handler('init','system','myformatplugin_init');
?&gt;</pre>
</blockquote>
<p>This will then register an import action which will be picked up by the administrator import export utility. Your action can access the information it needs to import with the call:</p>
<blockquote><p><code>$data = get_input('data');</code></p></blockquote>
<p>Elgg 1.0 will ship with native support for <a href="http://www.opendd.net">OpenDD</a> (both import and export) which will allow administrators to migrate between <a href="http://classic.elgg.org">Elgg classic</a> and the new codebase with a minimum amount of effort.</p>
<p>Elgg 1.0 also offers export views in JSON and PHP native, making it easier to reference the data directly and create mashups.</p>
<p>Over time we will be adding more import and export functionality, and I hope you will be too!</p>
<div class="wsbuttons">
	<div class="shareblob facebook">
		<div class="fb-like" data-href="http://www.marcus-povey.co.uk/2008/07/31/import-and-export-in-elgg-10-2/" data-send="false" data-layout="box_count" data-width="60" data-show-faces="false" data-colorscheme="light"></div>
	</div>

	<div class="shareblob google">
		<div class="g-plusone" data-size="tall" data-href="http://www.marcus-povey.co.uk/2008/07/31/import-and-export-in-elgg-10-2/"></div>
	</div>

	<div class="shareblob twitter">
		<div class="twitter">
			<a href="https://twitter.com/share?url=http%3A%2F%2Fwww.marcus-povey.co.uk%2F2008%2F07%2F31%2Fimport-and-export-in-elgg-10-2%2F&count=vertical" class="twitter-share-button" data-lang="en">Tweet</a>
			<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
		</div>
	</div>

</div>
	]]></content:encoded>
			<wfw:commentRss>http://www.marcus-povey.co.uk/2008/07/31/import-and-export-in-elgg-10-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

