File Objects
The file is a pretty simple object with only a few fields. Each file is linked to a person object representing the person who uploaded the file. In addition, the file may be linked to a content object.
Fields
| id | the unique id of this file |
|---|---|
| contentId | reference to a piece of content |
| userId | reference to the file's uploader |
| file_name | the descriptive name of this file. files uploaded via the edit profile script and default pods name the file 'img' because it is primarily used as an avatar. |
| original_name | the original filename of the file |
| description | a description of the file, or a caption for an image |
| extension | 3 character file extension |
| mime_type | the mime type of the file which is autodetected |
| changeDate | date this file was most recently changed |
| date | date this file was uploaded |
| original_file | url of uploaded original file |
| resized | url of resized image, as defined in the PeoplePods admin tool |
| thumbnail | url of the thumbnail image, as defined in the PeoplePods admin tool |
| minutes | minutes since the file was uploaded |
| tmp_name | temporary name of a file that has just been uploaded. this is found in the $_FILES array. |
Relationships
You can access the files of the owner by using the $file->creator() function, which returns a person object.
// access person object member functions
echo "Uploaded by: ";
$file->owner()->permalink();
// output the owner using a special template
$file->owner()->output('avatar');
You can also access the content that the file is attached to, using the handy $file->parent() function.
// access content values
$file->parent()->write('headline');
// is this file by the original poster?
if ($file->get('userId')==$file->parent()->get('userId')) {
// do something
}
Displaying Files
You can use the $file->output() function to output a file using its own templates, or you can access individual fields.
Templates for file objects are found in the files/ sub folder of your theme.
// output a file using the files/download.php template
$file->output('download');
// print an image link using the resized image
<img src="<? $file->write('resized'); ?>" />
// print a link to the original file
< a href="<? $file->write('original_file'); ?>" />
You might also want to send the actual contents of a file instead of just making a link to it. To do this, use the $file->download() function.
Image Files
When an image is uploaded, PeoplePods will automatically resize it into 2 sizes: a resized version, and a thumbnail version. The specifics of how the image is resized can be set using the PeoplePods Command Center tool.
You can tell whether or not a file is an image by using the $file->isImage() function.
PeoplePods can also automatically generate new sizes of an image using the $file->src() function:
// generate a version that is 100 pixels wide <img src="< $img->src(100); ?>" /> // generate a version that is 50 pixels wide and cropped to a square <img src="< $img->src(50,true); ?>" />
Loading Files
The vast majority of the time, you'll probably be displaying the files that are attached to the piece of content you are viewing, or that were uploaded by a specific person. To do this, simply use the $content->files() and $person->files() functions, which returns a list of the files in chronological order.
You can also load a specific file by it's id using the $POD->getFile() function.
If you need to query the file database on any of the file fields or fields in the related tables, use the $POD->getFiles() function.
// output the files from a piece of content
$content->files()->output();
// load a specific file (for editing, etc)
$file = $POD->getFile(array('id'=>1));
// load all files from a user,
// regardless of whether or not it was attached to content
$files = $POD->getFiles(array('userId'=>1));
// load all files from a user NOT attached to contnet
$files = $POD->getFiles(array('userId'=>1,'contentId'=>'null'));
// load all files from any piece of content in a specific group
$group_files = $POD->getFiles(array('d.groupId'=>5));
Adding and Removing File
The best way to add a file is to use the $content->addFile() function or the $person->addFile() function, which handles all the nitty gritty details.
To delete files, call $file->delete().
More about this function and it's related functions:
Download the latest version of PeoplePods!
0.71
Latest Version:
Release Notes
Recent Posts from Our Blog
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...
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...
Recently Updated Documentation
Recent Posts from The Forum
Tell me how you want to use PeoplePods, and I'll help you build it!
13 comments | 14 days ago
Does any one have Idea on implementing SSO applications like gigya SSO or RPXNOW SSO for single sign on access ?
5 comments | 15 days ago
BTW The pages in my admin panel are appearing like http://mydomain.com//admin/options/emails.php, http://mydomain.com//admin/options/themes.php Is this the reason for the trouble?
6 comments | 16 days ago
Does any one have any idea on changing the limit of charatcers ? For ex: 333 characters?
1 comment | 16 days ago


No comments have been posted yet.