How do I find a Folder, and get the ID of this folder i PyroCMS Files module, using PHP. Ideally I would like to do this below, but I cant find the function for get folder by name.
// This does not work
$folder = Files::find_folder_by_name("MyFolder");
$folder_id = $folder ["data"]["id"];
// This part works fine
if($folder_id==NULL)
{
$ar = Files::create_folder(0, "MyFolder");
$folder_id = $ar["data"]["id"];
}
There is not function named find_folder_by_name
. Try following with model:
$folder = $this->file_folders_m->get_by('name', 'MyFolder');
if(!$folder)
{
$ar = Files::create_folder(0, "MyFolder");
$folder_id = $ar["data"]["id"];
}
echo $folder->id; // Get folder ID
$folder
variable returns object.