Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

67 lines (57 sloc) 2.262 kB
* Consuming Linked Data from
* This example demonstrates fetching information about villages in Fife
* from
* First it fetches a list of villages that are members of the
* Wikipedia category 'Villages in Fife' and displays them as a list.
* If you click on an village, then it displays a page about that village
* with a title, synopsis and Google Map.
* @package EasyRdf
* @copyright Copyright (c) 2009-2013 Nicholas J Humfrey
* @license
require_once realpath(__DIR__.'/..')."/vendor/autoload.php";
require_once __DIR__."/html_tag_helpers.php";
$CATEGORY_ID = 4309010;
<head><title>EasyRdf Village Info Example</title></head>
<h1>EasyRdf Village Info Example</h1>
if (isset($_REQUEST['id'])) {
$graph = \EasyRdf\Graph::newAndLoad("".$_REQUEST['id']);
$village = $graph->primaryTopic();
print content_tag('h2',$village->label());
if ($village->get('foaf:depiction')) {
print image_tag(
print content_tag('p',$village->get('rdfs:comment'));
if ($village->get('geo:long')) {
$ll = $village->get('geo:lat').','.$village->get('geo:long');
print "<iframe width='425' height='350' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src=';ll=$ll&amp;output=embed'></iframe>";
echo "<br /><br />";
echo $graph->dump();
} else {
$graph = \EasyRdf\Graph::newAndLoad("".$CATEGORY_ID);
$category = $graph->primaryTopic();
print "<ul>\n";
foreach ($category->all('^rdf:type') as $resource) {
if (preg_match("|\d+)#id|", $resource, $matches)) {
print '<li>'.link_to_self($resource->label(), "id=".$matches[1])."</li>\n";
print "</ul>\n";
Jump to Line
Something went wrong with that request. Please try again.