Home » Documentation » What is PeoplePods? » SDK Documentation » Object Definitions » Content Object

Content Object

PeoplePods stores all of the content it manages in Content Objects. These are generic storage containers that can be customized to contain any kind of content you desire.

At the bare minimum, a piece of PeoplePods content consists of a headline and a content type. The headline field is a simple text field used as the display title of the content. The type field is also a text field: you can create as many types of content as you want by specifying different values for this field.

Content object's also optional contains fields for body text, an extermal link, an editorial status field, and a privacy information field. These can be used together in any configuration.

But the real power of the content object comes through using the Meta Field functionality, which allows you to append any field you want to any content object. Using this ability, you can customize your content objects to include any and all information that you need to store.

With the meta fields and the dynamic content typing, PeoplePods gives you very flexible access to your content. You should be able to query and display anything you can image with a few lines of code.

Content Objects are stored in the content table in the database.

Content Objects should always be created through the main $POD object using the $POD->getContent() or $POD->getContents() functions.

Fields

id the unique identifier of this content record in the db
userId the unique identifier of the "author" of this record. will in the vast majority of cases be the same as createdBy
headline REQUIRED - title of this content
type REQUIRED - a short string that defines what type of content this is
body the body text of this content
link space to store an arbitrary URL
status Editorial status field. Defaults to 'new' but can be set to 'approved' or 'featured'
createdBy the unique identifier of the person who created this record.
parentId the unique id of another piece of content considered to be the "parent" content, if any.
groupId the unique id of the group this content is a member of, if any.
privacy Describes the privacy setting of this piece of content. Defaults to public, indicating anyone can view this content. Can also be 'friends_only', 'group_only', or 'owner_only'
date date this content was created
changeDate date this content was last modified in any way
editDate date the core values of this content were last upated
commentDate date of the most recently added comment
flagDate date of the most recent change to the status field.
yes_votes number of yes votes that have been registered to this content
no_votes number of no votes that have been registered to this content
yes_percent percentage of total votes that are yes votes
no_votes percentage of total votes that are no votes.
stub URL friendly version of the headline which can also be used as a unique identifier for this post.
permalink URL to post's permalink page

Examples

Create a simple piece of content with just the minimum info:

$content = $POD->getContent();
$content->set('headline','This is a new post!');
$content->set('type','post');
$content->save();
echo "Here is your new post:";
$content->permalink();

Now, create a different kind of content with some extra fields:

$content = $POD->getContent();
$content->set('type','event'); // ad-hoc create a new content type 
$content->set('headline','Chester's Birthday'); // event title
$content->set('body','Chester is having a birthday party!');
$content->save();  // create the record in the db so we can use meta fields.

$content->addMeta('startDate','2009-03-15'); // add a new field
$content->addMeta('endDate','2009-03-15'); // add a new field
$content->addMeta('please_bring','BEER!'); // add a new field

echo "Your new event has been created!  ";
$content->permalink();
echo "Start: " . $content->write('startDate');
echo "End: " . $content->write('endDate');

We can query for content of any type...

$posts = $POD->getContents(array('type'=>'post'));
$events = $POD->getContents(array('type'=>'event'));

Or, you could look for content that matches specific parameters.

// load all the posts the current user created
$my_posts = $POD->getContents(array(
  'type'=>'post',
  'userId'=>$POD->currentUser()->get('id')
));


// load all the events where the start date is today
$today = date("Y-m-d");
$todays_events = $POD->getContents(array(
  'type'=>'event',
  'm.name'=>'startDate',
  'm.value'=>$today
));

Relationships

Each piece of content has a set of predefined relationships to people and other pieces of content within the site. These relationships are represented by cleverly named functions that return other objects or stacks of objects.

And don't forget, every content object inherits all the functions from the $Obj object. These functions include:

More about this function and it's related functions:

  • Discuss This Document

No comments have been posted yet.

Download Download the latest version of PeoplePods!

0.667 Latest Version:
Release Notes

A free membership is required to download PeoplePods.

  Already Registered? Login

Recent Posts from Our Blog

Developer Preview Launch!

I am very excited to announce the launch of PeoplePods version 0.666, THE DEVELOPER PREVIEW! After tons of hacking, I have tweaked the last line of code, and I am finally ready for a wider audience...