使用表达式引擎创建单事件 ICS 文件
我正在尝试基于表达式引擎通道内的单个条目创建 ICAL 文件,但我完成此操作的方法失败了。我尝试过以下操作:
- 将条目 ID 传递到新模板(创建文件),但在 EE 中似乎不赞成使用
$_GET
函数 使用以下命令创建会话变量条目 ID,但似乎无法将此变量添加到 {exp} 查询中:
{exp:channel:entries channel="gallery" entry_id="MY_PHP_VARIABLE" limit="1" show_future_entries="yes"}
我还没有尝试在每次使用 fwrite()
访问单个条目页面时创建一个平面文件并直接链接到它,但这似乎是一个代价高昂的举动。
PHP 有没有办法在我单击按钮时生成文件?也许会触发页面中编写的函数,这样我就不需要传递或检测 entry_id
?
I'm trying to create an ICAL file based on a single entry inside an Expression Engine channel but my methods of accomplishing this are failing. I've tried the following:
- Passing the entry ID into a new template (which creates the file) but using the
$_GET
function seems to be frowned upon in EE Creating a session variable with the entry ID but there seems to be no way of adding this variable to the {exp} query:
{exp:channel:entries channel="gallery" entry_id="MY_PHP_VARIABLE" limit="1" show_future_entries="yes"}
I haven't tried just making a flat file each time the single entry page is accessed with fwrite()
and linking directly to it, but that seems like a costly move.
Is there a way with PHP to make the file when I click a button? Maybe firing off a function written in the page so I don't need to pass or detect the entry_id
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我之前已经使用在输出上启用 PHP 的常规模板完成了此操作。
因此,您的 iCal 链接将是
/events/ical/{entry_id}
,您的events.group/ical.html
模板将如下所示:当然,详细信息可能会有所不同,取决于您是否使用日期字段的时间部分,或专用时间字段等,但您明白了。
I've done this before with a regular template with PHP enabled on output.
So your iCal link would be
/events/ical/{entry_id}
, and yourevents.group/ical.html
template would look something like:The details may vary of course, depending on whether you're using the time portion of your date fields, or a dedicated time field, etc, but you get the idea.
不确定您是否仍然需要这个,但我需要完全相同的东西并编写了一个插件来处理它。
https://github.com/expressodev/easy_icalendar
基本上,用法只是围绕标准通道条目标签,所以看起来像这样
您可以使用它在单击按钮时显示单个条目。只需创建一个名为
/events/ical
或其他名称的新模板,并使用 url/events/ical/url-title
(或entry_id)引用它。然后在您的频道条目循环中,使用标准
Easy iCal 将生成一个有效的、可下载的 ics 文件。如果您希望链接具有*.ics扩展名(有些读者很挑剔),请将entry_id放在段3中,将文件名放在段4中:
然后只需在您的ical模板中使用entry_id,并忽略段4
Not sure if you still need this, but I needed the exact same thing and wrote a plugin to handle it.
https://github.com/expressodev/easy_icalendar
Basically, the usage just revolves around a standard channel entries tag, so looks something like this
You can use it to show a single entry when you click a button. Just make a new template called
/events/ical
or something, and reference it using the url/events/ical/url-title
(or entry_id).Then in your channel entries loop, use the standard
Easy iCal will spit out a valid, downloadable ics file. If you want the link to have an *.ics extension (some readers are fussy), put the entry_id in segment 3, and the file name in segment 4:
Then just use the entry_id in your ical template, and ignore segment 4