gpt4 book ai didi

php - 如何在组件内部调用组件 [OctoberCMS]

转载 作者:可可西里 更新时间:2023-10-31 22:52:09 28 4
gpt4 key购买 nike

我想用一个变量调用一个组件内部的一个组件,像这样:enter image description here

这里是default.html的代码->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<div class="container">
<div class="row">
{% partial __SELF__ ~ "::category" category=__SELF__.category childscategory=__SELF__.childscategory%}
<div class="col-xs-3">
<strong>DATA</strong>
<ul class="list-group text-center">
{% partial __SELF__ ~ "::dates" files=__SELF__.files %}
</ul>
</div>

<div class="col-xs-3">
<strong>Nome do Ficheiro</strong>
<ul class="list-group text-center">
{% partial __SELF__ ~ "::files" files=__SELF__.files %}
</ul>
</div>

<div class="col-xs-3">
<strong>Descrição</strong>
<ul class="list-group text-center">
{% partial __SELF__ ~ "::description" files=__SELF__.files %}
</ul>
</div>

<div class="col-xs-1">
<strong>{{__SELF__.labelpresentation}}</strong>
<ul class="list-group text-center">
{% partial __SELF__ ~ "::download_1" files=__SELF__.files %}
</ul>
</div>
-> I WANT TO CALL THE COMPONENT HERE <-
</div>
</div>

如果你想让我发布更多代码,比如 .php,没关系

最佳答案

示例:在我的 ApplicationForm 组件中使用 fileUploader 组件。在 ApplicationForm 类中,添加:

public function init()
{
$component = $this->addComponent(
'Responsiv\Uploader\Components\FileUploader',
'fileUploader',
[
'deferredBinding' => true,
'maxSize' => $this->property('maxFileSize'),
'fileTypes' => $this->property('fileTypes'),
'placeholderText' => $this->property('placeholderText'),
]
);

$component->bindModel('cv', new Application());
}

然后在 ApplicationForm 组件的 View (default.htm) 中使用初始化的组件,如下所示:

{% component 'fileUploader' %}

关于php - 如何在组件内部调用组件 [OctoberCMS],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37855845/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com