php - 在 OctoberCMS 中将树枝可变数据传递给 php 代码块
问题描述
我正在尝试从树枝循环生成的图像中读取 exif 图像数据。我正在尝试将 {{image}} 变量传递给 PHP 函数 onEnd ()。所以我的问题是如何访问 PHP onEnd() 函数中的 {{image}} 变量。
前端树枝
{% for image in gallery %}
{% set path = '/storage/app/media' %}
{% set gallerySlug = record.gallery_folder %}
{% set tilda = '/' %}
{% set combinedLink = path ~ gallerySlug ~ tilda ~ image %}
{% set link = path ~ image %}
<div class="grid-item wow fadeInUp" data-wow-duration="1s" data-wow-delay="0s" data-tilt data-tilt-speed="250" data-tilt-max="5" data-tilt-perspective="250">
<a href="{{combinedLink}}" target="_blank"><img src="{{combinedLink | resize(1000)}}" alt="Camera: {{path}}"/></a>
</div>
{% endfor %}
PHP
function onEnd () {
$frontId = $this->components['builderDetails']->record->id;
$this["galleryLink"] = Db::table('foto')->where('id', $frontId)->value('gallery_folder');
$galleryLink= Db::table('foto')->where('id', $frontId)->value('gallery_folder');
$items = [ ];
$files = File::allFiles( 'storage/app/media/' .$galleryLink. '/' );
foreach ($files as $item) {
$items[] = $item->getFilename();
$this["path"] = $item; //I get everything except correct image name.
}
sort($items, SORT_NUMERIC); // Bigest file number first
$this['gallery'] = $items;
}
解决方案
推荐阅读
- forms - 在表单提交之前执行异步功能
- android - android studio - 在调试模式下从已安装的应用程序中取出样式
- sql - 在 Power Bi 中将 SQL 查询转换为 DAX 以从表中获取单个值
- math - 傅里叶逆变换虚部数的物理意义是什么?
- python - sympy.plotting.plot3d 不绘制常量函数
- python - 动态访问文本文件中的特定标签并获取其下的元素并再次从下一个单词开始并使用python获取其下的元素
- javascript - 带有 base64 嵌入字体的序列化 SVG 图像,在 IE Edge 中无法正确呈现
- rdf - 关于属性特征的问题
- vmware - 无法下载最新的 VimService.dll 文件
- docker - 如何正确共享一个 jupyter docker 来托管