Home » Documentation » $POD->registerPOD()

$POD->registerPOD()

The registerPOD() function should be used only within the settings.php file of a plugin pod. It is used to tell PeoplePods what the pod does, what URLs it handles, and what variables and settings it needs.

$POD->registerPOD(
   $pod_name,
   $pod_description,
   $URL_array,
   $VAR_array,
   $path_to_methods_file,
   $name_of_settings_function
);

The $pod_name parameter should be a short string which matches the folder name in which the pod lives. Thus, if you have a folder called '/readme/pod_registerpod/my_plugin/index.html', the $pod_name parameter should be 'my_plugin'.

The $pod_description parameter is a string which should contain a description of the pod and its functions. This description is used within the PeoplePods command center.

The $URL_array parameter is an associative array which should contain mappings between URLs and handler scripts. The keys of of the array are the URL patterns, and the values of the array are the actual handler scripts. The URL patterns should be constructed as RewriteRule-friendly regular expressions, while the value should point to a php file within the pod.

$URL_array = array(
  '^welcome$'=>'/readme/pod_registerpod/my_plugin/handler.html',
  '^welcome/(.*)'=>'/readme/pod_registerpod/my_plugin/handler_mode_1.html',
  '^goodbye$'=>'/readme/pod_registerpod/my_plugin/goodbye.html'
);

The $VAR_array parameter should contain an associative array of key value pairs. These pairs will become static system options, accessible via the $POD->libOptions() function.

// in settings.php
$VAR_array = array(
  'foo'=>'bar',
);

// in any PeoplePods script:
$val = $POD->libOptions('foo');

The primary use of this of this parameter is to modify the automatically generated permalink and editlink values for a new content type. If your content type is called "post," you would define variables called "post_document_path" and "post_document_editpath":

// in settings.php
$VAR_array = array(
  'post_document_path'=>'posts',
  'post_document_editpath'=>'edit'
);


// in any peoplepods script:
// create new content
$doc = $POD->getContent();

$doc->type = 'post';
$doc->headline = 'Test Post';
$doc->save();

echo $doc->permalink;
// $doc->permalink will be:
// http://mydomain.com/posts/test-post
// $doc->editlink will be:
// http://mydomain.com/edit/test-post

The $path_to_methods_file parameter should contain the path to the methods.php file included in the pod. If no methods file is included, this parameter is not necessary.

99.99% of the time, this should be set to:

$path_to_methods = dirname(__FILE__) . "/methods.html";

The final parameter is the name of the settings function. This parameter is also optional. The settings function is used by the PeoplePods command center to create a settings form to collect dynamic system options.

Settings functions are described in more detail here.

With all of these variables combined, you might have a call that looks something like this:

$POD->registerPOD(
  'my_post_type',
  'a custom pod that sets up the "post" content type',
  array(
    '^posts/(.*)'=>'/readme/pod_registerpod/my_custom_pod/post_handler_stub_1.html',
    '^edit/(.*)'=>'/readme/pod_registerpod/my_custom_pod/edit_handler_id_1.html',
  ),
  array(
    'post_document_path'=>'posts',
    'post_document_editpath'=>'edit',
  ),
  dirname(__FILE__)."/methods.html",
  'postTypeSetup'
);
  • Discuss This Document

No comments have been posted yet.

Download Download the latest version of PeoplePods!

0.8 Latest Version:
Release Notes

Join the PeoplePods developer network and get direct access to documentation, additional plugins, and our forums!

  Already Registered? Login

Recent Posts from Our Blog

Get free help with PeoplePods on Tuesday, Oct 12

Hey Hackers! Want to learn about PeoplePods? Need help getting started? Have questions about building plugins or modifying themes? Join us for our first PeoplePods Office Hours on Tuesday,...

PeoplePods 0.8 now available! Developer Office Hours Announced

PeoplePods version 0.8 was officially released on 10/10/10! This version is a substantial upgrade from 0.7, bringing new tools and a new interface to the content management and moderation "command...

0.71 Released - Inbox bug fixed

PeoplePods version 0.71 has been released. This version is a maintenance release which fixes a problem with the private messaging inbox. Existing PeoplePods sites can upgrade to the newest...

PeoplePods powers MediaBugs.org and the Helsinki Design Lab

April saw the launch of two brand new PeoplePods-powered applications. These new sites use the latest version of PeoplePods - 0.8 - which will be available to download at the end of...

Version 0.7 Now Available

Last night, I uploaded a new release of PeoplePods: version 0.7. The most exciting new features in this version are: new dynamic image resizing options, a faster comment polling system, new ways...