十月CMS |在重新排序列表上显示图像

时间:2017-03-28 10:53:54

标签: php laravel octobercms octobercms-backend

有一种方法可以打开列表控制器上的重新排序功能,并按name重新排序列表项...

但是有一些方法可以在重新排序列表中显示图像而不是文本吗?

enter image description here

我现在拥有的东西:

config_reorder.yaml

title: 'Configurar a ordem'
azuRef: ref
azuImg: image
modelClass: Frama\Azulejos\Models\Azulejo
toolbar:
buttons: reorder_toolbar

ReorderController.php

...
public function __construct($controller)
{
    ...

    $this->azuImg = $this->getConfig('azuImg', $this->azuImg);

    ...

}
...

结果当然我得到了文字......而且我不知道该怎么做......我需要访问路径或(更好)getThumb

enter image description here

修改

好的我可以通过改变刺痛来获得类似的东西:

json_decode($this->reorderGetRecordImg($record))->path

但是如何让拇指工作?

1 个答案:

答案 0 :(得分:1)

好的解决方案很容易,因为*** k:)

模块/后端/行为/ rendercontroller /分音/ _records.htm

<?php foreach ($records as $record): ?>
    <!-- ... -->

    <img src="<?= $record->image->getThumb(50,'auto',['mode' => 'landscape']) ?>" alt="">

     <!-- ... -->
<?php endforeach ?>

模块/后端/行为/ rendercontroller /分音/ _records.htm

<?php foreach ($records as $record): ?>
    <!-- ... -->

    <img src="<?= $this->reorderGetRecordImg($record) ?>" alt="">

     <!-- ... -->
<?php endforeach ?>

ReorderController.php

...
public function __construct($controller)
{
    ...

    $this->azuImg = $this->getConfig('azuImg', $this->azuImg);

    ...

}
...
public function reorderGetRecordImg($record)
{
    return $record->image->getThumb(50,'auto',['mode' => 'landscape']);
}
...