2016-06-16 3 views
3

Я хочу, чтобы вызвать компонент внутри компонента с переменной, например: enter image description hereКак вызвать компонент внутри компонента [OctoberCMS]

Вот код 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, это нормально

+1

Не ленитесь, после реального фрагменты кода вместо скриншотов это может помочь другим, повторно используя ваш код, чтобы ответить на ваш вопрос. – Stacked

ответ

2

Пример: используйте компонент fileUploader в моем ApplicationForm компоненте. В классе 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()); 
} 

И в представлении (default.htm) компонента ApplicationForm использовать инициализирован компонент, как так:

{% component 'fileUploader' %}