How do I call a component inside a component [OctoberCMS](如何在组件内调用组件 [OctoberCMS])
问题描述
我想用变量调用组件内部的组件,像这样:
I want to call a component inside a component with a variable, like this:
这是default.html的代码->
Here's the code of the default.html->
<script src="aHR0cHM6Ly9hamF4Lmdvb2dsZWFwaXMuY29tL2FqYXgvbGlicy9qcXVlcnkvMS4xMi4yL2pxdWVyeS5taW4uanM="></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 的代码,没关系
If you want me to post more code like the .php, it's ok
推荐答案
示例:在我的 ApplicationForm 组件中使用 fileUploader 组件.在 ApplicationForm 类中,添加:
Example: use the fileUploader component in my ApplicationForm component. In ApplicationForm class, add this:
public function init()
{
    $component = $this->addComponent(
        'ResponsivUploaderComponentsFileUploader',
        'fileUploader',
        [
            'deferredBinding'   => true,
            'maxSize'           => $this->property('maxFileSize'),
            'fileTypes'         => $this->property('fileTypes'),
            'placeholderText'   => $this->property('placeholderText'),
        ]
    );
    $component->bindModel('cv', new Application());
}
并且在 ApplicationForm 组件的视图(default.htm)中使用初始化的组件,如下所示:
And in the view (default.htm) of the ApplicationForm component use the initialized component like so:
{% component 'fileUploader' %}
                        这篇关于如何在组件内调用组件 [OctoberCMS]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在组件内调用组件 [OctoberCMS]
				
        
 
            
        - Mod使用GET变量将子域重写为PHP 2021-01-01
 - Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
 - 没有作曲家的 PSR4 自动加载 2022-01-01
 - Laravel 仓库 2022-01-01
 - 正确分离 PHP 中的逻辑/样式 2021-01-01
 - PHP Count 布尔数组中真值的数量 2021-01-01
 - SoapClient 设置自定义 HTTP Header 2021-01-01
 - 从 PHP 中的输入表单获取日期 2022-01-01
 - 如何定位 php.ini 文件 (xampp) 2022-01-01
 - 带有通配符的 Laravel 验证器 2021-01-01
 
				
				
				
				