Skip to content

Instantly share code, notes, and snippets.

@kanetei
Created April 11, 2017 03:30
Show Gist options
  • Save kanetei/ffd7fb2887cf02ca728f2d6ce05e044e to your computer and use it in GitHub Desktop.
Save kanetei/ffd7fb2887cf02ca728f2d6ce05e044e to your computer and use it in GitHub Desktop.
【concrete5】特定のエクスプレスオブジェクトで、属性(チェックボックス)にチェックがない時に項目を表示するカスタマイズ
<?php
namespace Application\Block\ExpressEntryList;
use Concrete\Core\Express\Entry\Search\Result\Result;
use Concrete\Core\Express\EntryList;
class Controller extends \Concrete\Block\ExpressEntryList\Controller
{
public function view()
{
$entity = $this->entityManager->find('Concrete\Core\Entity\Express\Entity', $this->exEntityID);
if (is_object($entity)) {
$category = $entity->getAttributeKeyCategory();
$list = new EntryList($entity);
if ($this->displayLimit > 0) {
$list->setItemsPerPage(intval($this->displayLimit));
}
$set = unserialize($this->columns);
$defaultSortColumn = $set->getDefaultSortColumn();
if ($this->request->query->has($list->getQuerySortDirectionParameter())) {
$direction = $this->request->query->get($list->getQuerySortDirectionParameter());
} else {
$direction = $defaultSortColumn->getColumnDefaultSortDirection();
}
if ($this->request->query->has($list->getQuerySortColumnParameter())) {
$value = $this->request->query->get($list->getQuerySortColumnParameter());
$column = $entity->getResultColumnSet();
$value = $column->getColumnByKey($value);
if (is_object($value)) {
$list->sanitizedSortBy($value->getColumnKey(), $direction);
}
} else {
$list->sanitizedSortBy($defaultSortColumn->getColumnKey(), $direction);
}
if ($this->request->query->has('keywords') && $this->enableSearch) {
$list->filterByKeywords($this->request->query->get('keywords'));
}
if($entity->getHandle() === 'service') {
$list->filterByAttribute('service_visibility', false);
}
if($entity->getHandle() === 'staff') {
$list->filterByAttribute('staff_visibility', false);
}
$tableSearchProperties = array();
$searchPropertiesSelected = (array) json_decode($this->searchProperties);
foreach($searchPropertiesSelected as $akID) {
$ak = $category->getAttributeKeyByID($akID);
if (is_object($ak)) {
$tableSearchProperties[] = $ak;
$type = $ak->getAttributeType();
$cnt = $type->getController();
$cnt->setRequestArray($_REQUEST);
$cnt->setAttributeKey($ak);
$cnt->searchForm($list);
}
}
$result = new Result($set, $list);
$pagination = $list->getPagination();
if ($pagination->getTotalPages() > 1) {
$pagination = $pagination->renderDefaultView();
$this->set('pagination', $pagination);
}
$this->set('list', $list);
$this->set('result', $result);
$this->set('entity', $entity);
$this->set('tableSearchProperties', $tableSearchProperties);
$this->set('detailPage', $this->getDetailPageObject());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment