file content management
DESCRIPTION
Learn how to manipulate file content of ProdigyView’s built-in content management system. Also learn how to upload a file directly into the cms.TRANSCRIPT
![Page 2: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/2.jpg)
OverviewObjective
Learn how to manipulate file content of ProdigyView’s built-in content management system. Also learn how to upload a file directly into the cms.
Requirements
Installed version of ProdigyView with a database
Understanding of base content
Understanding of the DEFINES in ProdigyView
Estimated Time
12 minuteswww.prodigyview.com
![Page 3: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/3.jpg)
Follow Along With Code Example
1. Download a copy of the example code at www.prodigyview.com/source.
2.Install the system in an environment you feel comfortable testing in.
3.Proceed to examples/content/FileContentWithFileExample.php
![Page 4: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/4.jpg)
What Is File Content?
File content is a generic way of storing information related to a file. Unlike video, audio and image content, file content allows any kind of file to be specified.
Document System
Versioning
File Management
Generic Uploaded Files
Attachment Management
Etc
www.prodigyview.com
![Page 5: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/5.jpg)
Extends Base ContentLike the other content types, file content extends base content. This means it has all the fields that base content has in addition to the fields that describes a file.
File Content Fields Base Content Fields
www.prodigyview.com
![Page 6: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/6.jpg)
Create File ContentFile content is relatively easy to create. In an array, passed defined fields into PVContent::createFileContent method.
1. Define the content that will be stored as file content
2. Pass the array to PVContent::createFileContent3. Return content id
![Page 7: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/7.jpg)
Database View
Remember that the files content utilizes both the base content and file content fields. This is accomplished by joining two tables. Your two tables in the database should look something like below.
Base Content Database View
File Content Database View
![Page 8: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/8.jpg)
File Content Fields
The previous slide only showed a few fields that can be set when defining file content. Here is a complete list of fields that apply only to the file content.
www.prodigyview.com
![Page 9: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/9.jpg)
Creating A File with FileSimilar to creating normal file content, creating file content with a file is accomplished through setting arguments correctly. In the example below, we are using a file from our file system. But it can be set the same way using PHP’s $_FILES global.
1. Name of the file 2. The location the file currently resides
3. The size of the file 4. The type of file
![Page 10: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/10.jpg)
Create File Content With a File
Now pass those arguments to the PVContent::createFileWithFile() method. The content id will be return and the image placed in your PV_FILE define folder.
www.prodigyview.com
![Page 11: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/11.jpg)
Database ViewThe file will be uploaded will be placed in the PV_FILE folder and a reference link will be placed in the database. Your database should look something like this:
1. Mime type 2. File size
3. Auto generated random file name for to reference
www.prodigyview.com
![Page 12: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/12.jpg)
Search for File ContentUsing the syntax from the PV Standard Search Query, we can search for content related to files on fields for both base content and file content.
1. Search based on the passed arguments
2. Pass args into getFileContentList() method3. Returns an array of arrays
that contains the list of file content
![Page 13: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/13.jpg)
Iterate Through The ListNext we can iterate through the list of file content to see the data we just added.
1. Iterate through the fields base content
2. With the automatic joining of the tables, file content fields are also returned
![Page 14: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/14.jpg)
Retrieving File ContentFile content can also be retrieved directly using the content id. The data associated with that content id will be returned in array.
1. Pass in the content id
2. Content is returned in an array
3. Get the values of the array by specifying the associated index
![Page 15: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/15.jpg)
Updating File ContentThat array contains the information for updating the file content. Simply change a value at an index in the array and pass it to PVContent::updateFileContent() method. Remember the content_id variable is required.
1. Update the data determining if the file is downloadable and the max downloads
2. Pass the array back to update
![Page 16: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/16.jpg)
Deleting File Content
The last action to take place is deleting the file content. To delete content, we pass the content id into PVContent::deleteContent method.
All the content types(audio, video, event, etc) use the PVContent::deleteContent method. Associated files will be deleted also.
www.prodigyview.com
![Page 17: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/17.jpg)
Review1. Create file content by passing an array of arguments
into PVContent::createFileContent()
2. PVContent::createFileContent() will return the id of the newly generated file content
3. Search for file content by using the syntax from PV Standard Search Query and passing those arguments into PVContent::getFileContentList()
4. Update content by passing an array of accepted fields in PVContent::updateFileContent(). The content_id must be present for this method to work.
5. Delete file content by passing the content_id into PVContent::deleteContent().
www.prodigyview.com
![Page 18: File Content Management](https://reader033.vdocument.in/reader033/viewer/2022061214/547e02f2b4af9f88778b46dc/html5/thumbnails/18.jpg)
API ReferenceFor a better understanding of file content, visit the api by clicking on the link below.
PVContent
www.prodigyview.com
More Tutorials
For more tutorials, please visit:
http://www.prodigyview.com/tutorials