如何在组件内调用组件 [OctoberCMS]

How do I call a component inside a component [OctoberCMS](如何在组件内调用组件 [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="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]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)