Skip to content
haschek edited this page Sep 14, 2011 · 1 revision

Develop Controllers

In the controllers, the rdf data is extractracted, processed, merged, and so on. Here you write the variables to the content object, what is rendered via the templates.

Preamble: myfoafpressextensions is your folder on the same level with the foafpressapp folder.

$ cd /var/www/yourfoafpressfolder
$ mkdir myfoafpressextensions

Overwrite standard controllers, add controllers for other resource types

This is only a short example, using the controller for foaf:Group resources. You can get help at the mailing list foafpress@librelist.com.

Creating your resource controller

E.g the controller for foaf:Group resources, myfoafpressextensions/controllers/foaf/Group.php:

<?php

require_once './../foafpressapp/core/controllers/foaf/Group.parent.php';
class Foaf_Group_Controller extends Foaf_Group_Controller_Parent
{
    // doing stuff, create, extend, overwrite methods
}

?>

Same with foaf/Person.php, doap/Project.php, etc ... it is not necessary to use the parent controller from Foafpress but it is recommended.

Edit your fp-config.php:

$c['plugin']['folder'][] = dirname(__FILE__).'/myfoafpressextensions/controllers/';

That's all!

It's not necessary to copy the whole controller scope, e.g. if you don't have foaf/Person.php in your controller folder, Foafpress falls back to its own default controller.