如何在组件内调用组件 [OctoberCMS] [英] How do I call a component inside a component [OctoberCMS]

查看:18
本文介绍了如何在组件内调用组件 [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="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 的代码,没关系

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]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆