Home » Documentation » What is PeoplePods? » SDK Documentation » Object Definitions » PeoplePods Objects » $POD->getContent()

$POD->getContent()

Returns one specific Content Object. This function can be used to load existing content from the database, or create a new piece of content.

Loading Content

To load an existing piece of content, pass in ONE of the following parameters:

  • id - db id of the content
  • stub - unique stub of the content

The vast majority of the time, you will load specific pieces of content by their stubs. For example, the following code will load the content with the stub name 'about'

$content = $POD->getContent(array(
  'stub'=>'about'
));

Creating Content

To create content, you can either load an empty content object and set values for its fields, or pass in default values to the constructor.

Create a brand new, empty content object:

$new_content = $POD->getContent();
$new_content->set('headline','This is a new piece of content!');
$new_content->set('type','post');
$new_content->save();

Or, pass in values:

$new_content = $POD->getContent(array(
  'headline' => 'This is the default headline',
  'type' => 'post'
));
$new_content->save();

Errors

Be sure to check for errors! In some instances, the content object may not be created properly, and will throw an error.

if (!$new_content->success()) {
  echo $new_content->error();
}
  • Discuss This Document

No comments have been posted yet.

Download Download the latest version of PeoplePods!

0.7 Latest Version:
Release Notes

A free membership is required to download PeoplePods.

  Already Registered? Login

Recent Posts from Our Blog

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...

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...