Skip to content

[TASK] Make page fields to select configurable via configuration for … #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Classes/Domain/Repository/MenuRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ public function getPageTree(int $startPageId, int $depth, array $configuration):
return $page;
}

protected function getPageFields(array $configuration): string
{
if (!empty($configuration['pageFields'])) {
$items = GeneralUtility::trimExplode(',', $configuration['pageFields'], true);
// just make sure if we have a field list to not have "*" included
if (count($items) > 1 && ($key = array_search('*', $items)) !== false) {
unset($items[$key]);
}
$pageFields = GeneralUtility::uniqueList(implode(',', $items));
} else {
$pageFields = '*';
}
return $pageFields;
}

protected function getExcludeDoktypes(array $configuration): array
{
if (!empty($configuration['excludeDoktypes'])) {
Expand Down Expand Up @@ -137,10 +152,11 @@ public function getSubPagesOfPage(int $pageId, int $depth, array $configuration)
$excludedPagesArray = GeneralUtility::intExplode(',', (string)$configuration['excludePages']);
$whereClause .= ' AND uid NOT IN (' . implode(',', $excludedPagesArray) . ')';
}
$pageFields = $this->getPageFields($configuration);
$excludedDoktypes = $this->getExcludeDoktypes($configuration);
$pageTree = $this->pageRepository->getMenu(
$pageId,
'*',
$pageFields,
'sorting',
'AND doktype NOT IN (' . implode(',', $excludedDoktypes) . ') ' . $whereClause,
false
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ Pure TypoScript-based solution:
page.10.excludePages = 4,51
# 0: default, 1 to include nav_hide = 1 pages
page.10.includeNotInMenu = 0
# if pageFields are not set, we take "*" from pages, but you can define
page.10.pageFields = uid,pid,title,slug
page.10.renderObj.level0 = TEXT
page.10.renderObj.level0.typolink.parameter.data = field:uid
page.10.renderObj.level0.typolink.ATagParams = class="active"
Expand All @@ -91,6 +93,7 @@ Fluid-based solution:
page.10.dataProcessing.10.entryPoints = 23,13
page.10.dataProcessing.10.depth = 3
page.10.dataProcessing.10.excludePages = 4,51
page.10.dataProcessing.10.pageFields = uid,pid,title,slug
# 0: default, 1 to include nav_hide = 1 pages
page.10.dataProcessing.10.includeNotInMenu = 0
page.10.dataProcessing.10.as = mobilemenu
Expand Down