Simplepie 包括不存在的幻象外壳

发布于 2024-09-29 23:48:03 字数 737 浏览 0 评论 0原文

我将两个提要与附件结合起来,没有附件的项目将显示为空附件。

以下代码中的违规位以粗体显示:

<item>
<title><?echo $item->get_title(); ?></title>
<guid><? echo $item->get_permalink(); ?></guid>
<link><? echo $item->get_permalink(); ?></link>
**<? if ($enclosure = $item->get_enclosure()) {echo "<enclosure url='"
.$enclosure->get_link() ."' length='" .$enclosure->get_length() ."' type='"
.$enclosure->get_type() ."' />";} ?>**
<description>
<? echo $item->get_title(); ?>
</description>
</item>

没有附件的项目显示为空附件 URL、长度和类型:

所有真实的附件都会按其应有的方式显示,包括网址、长度和类型。我在 Simplepie 支持页面上阅读了一些帖子,但没有找到解决方案。

谢谢!

I am combining two feeds, with enclosures, and items that don't have enclosures are showing up with empty enclosures.

Here's the code with the offending bit in bold:

<item>
<title><?echo $item->get_title(); ?></title>
<guid><? echo $item->get_permalink(); ?></guid>
<link><? echo $item->get_permalink(); ?></link>
**<? if ($enclosure = $item->get_enclosure()) {echo "<enclosure url='"
.$enclosure->get_link() ."' length='" .$enclosure->get_length() ."' type='"
.$enclosure->get_type() ."' />";} ?>**
<description>
<? echo $item->get_title(); ?>
</description>
</item>

Items with no enclosures show up with an empty enclosure url, length, and type:

All real enclosures show up as they should with url, length and type. I read a few threads on the Simplepie support page, but came up with no solution.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

原来分手还会想你 2024-10-06 23:48:03

我不了解 Simplepie,但看看代码,$item->get_enclosure() 可能返回一个计算结果为 true 的对象,但为空。因此,也许您应该将 if 的条件更改为:

<? $enclosure = $item->get_enclosure(); if ($enclosure->get_link()) {...

I don't know about Simplepie, but looking at the code, $item->get_enclosure() probably returns an object that evaluates to true, but is empty. So maybe you should change the condition of the if to:

<? $enclosure = $item->get_enclosure(); if ($enclosure->get_link()) {...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文