SilverStripe 보고서를 처음 사용하지만이 특정 문제와 관련된 항목을 지금까지 찾을 수 없었습니다.SilverStripe 3.4 사용자 지정 보고서 - 쉽게 편집 할 수 있도록 파일 이름을 사용자 지정 보고서의 링크로 설정하십시오.
사이트의 모든 이미지와 파일을 gridview에 나열하는 사용자 지정 보고서가 있지만 사람들이 파일 이름을 클릭하고 이미지 나 파일로 이동하여 편집 할 수 있도록하고 싶습니다. 또는 각 이미지 및 파일에 대한 편집 단추가 있어야합니다. 파일이나 이미지를 편집하고 싶다면 보고서를 떠나고 파일 탭으로 가서 파일/이미지를 검색 한 다음 편집하려면 클릭하십시오. 그것은 지루한 일입니다.
cms/code/reports의 기존 보고서 예제를 기반으로 보고서에서 페이지 제목을 클릭 할 수있는 방법이 있다는 것을 알고 있습니다. 하지만 업로드 된 이미지 및 파일에 연결하는 것과 관련된 내용은 없습니다.
이렇게하는 방법이 있습니까? 여기
내 사용자 정의 보고서에 대한 코드입니다 :<?php
class CustomSideReport_ListofImagesAndFiles extends SS_Report {
// the name of the report
public function title() {
return 'All Images and Files';
}
// what we want the report to return
public function sourceRecords($params = null)
{
return File::get()
->sort('Title');
}
// which fields on that object we want to show
public function columns() {
return array(
"Title" => 'Image Title',
'Filename' => array(
"Filename" => "Filename",
"link" => true,
),
);
}
}
이 작동하지 않습니다 "link" => true
를 사용하여 - 그것은 옳지 않다 페이지 링크를 만들려고합니다. "편집"및 "CanEdit"시도했습니다. 이 이제까지 최고의 솔루션의 경우
// which fields on that object we want to show
public function columns()
{
$linkBase = singleton('CMSFileAddController')->Link('EditForm/field/File/item');
$linkBaseEditLink = str_replace("/add","",$linkBase);
$fields = array(
'Title' => 'Title',
'AbsoluteLink' => array(
'title' => _t('CustomSideReport_ListofImagesAndFiles.ColumnFilename', 'Filename'),
'formatting' => function($value, $item) use ($linkBaseEditLink) {
return sprintf('<a href="%s">%s</a>',
Controller::join_links($linkBaseEditLink, $item->ID."/edit"),
strstr($value, '/assets/', false)
);
}
)
);
return $fields;
}
나도 몰라 - 작동이, 나는 할 수 없습니다 :