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

标签 php laravel components frontend octobercms

我想用一个变量调用一个组件内部的一个组件,像这样: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/

相关文章:

php codeigniter - 在 x 次后自动发送给用户,无需单击任何按钮

php - 学生每篇论文分数的数据库设计

php - Laravel Eloquent - 混合了 snake_case 和 camelCase 列的现有数据库

php - 拉维尔 4 : Count relationship within whereHas

javascript - React 组件、MongoDB 和传递 key - TypeError : Cannot read property '_id' of undefined

javascript - React JS - 如何将不同的 Prop 传递到其他 Prop 的映射中

php - 在 PHP 中,我应该使用今天的日期函数还是 MySQL 中的 curdate()?

php - 未找到类 'Zend_Form_Subform'

linux - 让 apache 只读取一个 php 文件

javascript - 将数据传递给单个文件 Vue 组件