Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何从Rainlab博客插件获取特色图片的url?_Php_Octobercms_Octobercms Plugins_October Form Controller - Fatal编程技术网

Php 如何从Rainlab博客插件获取特色图片的url?

Php 如何从Rainlab博客插件获取特色图片的url?,php,octobercms,octobercms-plugins,october-form-controller,Php,Octobercms,Octobercms Plugins,October Form Controller,我需要知道一个特色图片的url附加在一个博客文章与Rainlab博客插件在10月CMS 图像保存在类似“../storage/app/uploads/public/59f/112”的目录中 我需要在我保存帖子的那一刻就知道它,因为我想获取url以将其保存在另一个表中,它可以从另一个php文件或系统(例如Android应用程序)访问该表,但我不能这样做 我尝试使用(在FormController.php中)查找帖子: $modelP = Post::find($this->controlle

我需要知道一个特色图片的url附加在一个博客文章与Rainlab博客插件在10月CMS

图像保存在类似“../storage/app/uploads/public/59f/112”的目录中

我需要在我保存帖子的那一刻就知道它,因为我想获取url以将其保存在另一个表中,它可以从另一个php文件或系统(例如Android应用程序)访问该表,但我不能这样做

我尝试使用(在FormController.php中)查找帖子:

$modelP = Post::find($this->controller->vars['formModel']['id']);
$featuredImage = $modelP->featured_image->getPath();
但不起作用,我得到了blog对象,但它说,特色图片不是一个变量

在表system_文件中,我只能获取文件名(disk_name),但不能获取整个url,我不知道它保存在哪个目录中


有人能帮我吗?

它不是单数,而是复数

$featuredImage = $modelP->featured_images()->first();

编辑:首先使用它的单数形式,而不是复数形式

$featuredImage = $modelP->featured_images()->first();

编辑:首先使用

如果您使用的是rain lab插件,那么我们确实有一些解决方案

首先,它的特色图片非特色图片

它将返回一组图像,所以如果您需要它的第一个图像,那么您可以替换如下代码

$modelP = Post::find($this->controller->vars['formModel']['id']);
$featuredImage = $modelP->featured_images->first()->getPath();
$featuredImage这是图像的完整路径


任何其他困惑,请评论,快乐编码:)

如果您使用的是rain lab插件,那么我们确实有一些解决方案

首先,它的特色图片非特色图片

它将返回一组图像,所以如果您需要它的第一个图像,那么您可以替换如下代码

$modelP = Post::find($this->controller->vars['formModel']['id']);
$featuredImage = $modelP->featured_images->first()->getPath();
$featuredImage这是图像的完整路径


任何其他的困惑请评论,快乐编码:)

你把代码放在了哪个动作中?在FormController.php->create_onSave()中,你把代码放在了哪个动作中?在FormController.php->create_onSave()中,谢谢。Yes是复数形式,但带有get()返回十月\Rain\Database\Collection对象。我需要gePath(),谢谢。Yes是复数形式,但带有get()返回十月\Rain\Database\Collection对象。我需要gePath()。