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_percent | 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 |
| hidden | Default false. Set to true to hide a document from public view (as in non-destructive delete) |
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.
- $Content->children() - returns a stack of content objects whose parentId is set to $Content's id
- $Content->comments() - returns a stack of comments associated with this content.
- $Content->files() - returns all the files associated with this content.
- $Content->tags() - returns a stack of all the tags asssigned to this content.
- $Content->group() - returns a group object defined by $content's groupId field.
- $Content->parent() - returns a content object defined by $Content's parentId field.
- $Content->author() - returns a person object defined by $content's userId field.
- $Content->creator() - returns a person defined by $content's createdBy field.
And don't forget, every content object inherits all the functions from the $Obj object. These functions include:
- $Content->get()
- $Content->set()
- $Content->write()
- $Content->writeFormatted()
- $Content->htmlspecialwrite()
- $Content->addMeta()
- $Content->removeMeta()
- $Content->getMeta()
- $Content->addFlag()
- $Content->removeFlag()
- $Content->toggleFlag()
- $Content->hasFlag()
- $Content->addTag()
- $Content->removeTag()
- $Content->hasTag()
- $Content->tagsFromString()
- $Content->tagsAsString()
- $Content->success()
- $Content->error()
- $Content->errorCode()
- $Content->asArray()
More about this function and it's related functions:
- $Content->files()
- $Content->output()
- $Content->isEditable()
- $Content->save()
- $Content->delete()
- $Content->addComment()
- $Content->markCommentsAsRead()
- $Content->goToFirstUnreadComment()
- $Content->group()
- $Content->setGroup()
- $Content->changeStatus()
- $Content->vote()
- $Content->unvote()
- $Content->permalink()
- $content->addFile()
Download the latest version of PeoplePods!
0.9
Latest Version:
Release Notes
Recent Posts from Our Blog
Version 0.9 is here!
The latest version of PeoplePods is now available for download! This version features a drastically revamped theme which is now valid HTML5, a completely rewritten JSON-powered API, many...
Ben Brown on how running a community is like throwing a giant, never-ending party
An interview I did with OpenSource.com is now online! Read it here. In it, I discuss how running an online community is like throwing a giant, never-ending party, how open source techniques...
Recently Updated Documentation
Recent Posts from The Forum
Super noob question: I have everything installed correctly and am going through the steps. I have my database set-up. I have the database name,...
0 comments | 3 hours ago
I can't verify my account :(
2 comments | 3 days ago
Jquery UI problem. I having an issue for implementing UI on my theme, all reference are ok (304) on net console. http://un1v.altervista.org/ I have...
0 comments | 8 days ago


No comments have been posted yet.