如何使用PHP找到文件夹,并获取此文件夹的ID,即PyroCMS Files模块。 理想情况下,我想在下面执行此操作,但我无法按名称找到get文件夹的功能。
// 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"];
}
答案 0 :(得分:2)
没有名为find_folder_by_name
的功能。尝试使用模型:
$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
变量返回对象。