Skip to content

Commit

Permalink
ADD new condition
Browse files Browse the repository at this point in the history
to disable subpages in navigation color.
You can use the following SETUP to disable subpages nav color:
page.10.settings.navigationColor.nosubpages = 1
  • Loading branch information
t3solution authored Jul 14, 2021
1 parent 7189fd4 commit 1c6d501
Showing 1 changed file with 49 additions and 35 deletions.
84 changes: 49 additions & 35 deletions Classes/DataProcessing/ConfigProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu
} else {
$processedData['config']['navbar']['navbarPlusicon'] = $processedRecordVariables['navbarPlusicon'];
}

$processedData['config']['navbar']['image'] = $processedRecordVariables['navbarImage']
? $processedRecordVariables['navbarImage'] : $contentObjectConfiguration['settings.']['navbar.']['image.']['defaultPath'];
$processedData['config']['navbar']['toggler'] = $processedRecordVariables['navbarToggler'];
Expand Down Expand Up @@ -280,7 +281,7 @@ public function process(ContentObjectRenderer $cObj, array $contentObjectConfigu

$extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('t3sbootstrap');
if ( $extConf['navigationColor'] ) {
$processedData['config']['navbar']['navColorCSS'] = self::getNavigationColor();
$processedData['config']['navbar']['navColorCSS'] = self::getNavigationColor($contentObjectConfiguration);
}
}

Expand Down Expand Up @@ -482,9 +483,10 @@ protected function getBackgroundImageUtility(): BackgroundImageUtility
/**
* Generate CSS for navigation color
*
* @param array $contentObjectConfiguration The configuration of Content Object
* @return string
*/
protected function getNavigationColor(): string
protected function getNavigationColor($contentObjectConfiguration): string
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$result = $queryBuilder
Expand All @@ -503,43 +505,55 @@ protected function getNavigationColor(): string
$navbarColors = $result->fetchAll();
$navbarColorCSS = '';

foreach($navbarColors as $navbarColor) {

$treePages = $this->getTreePids($navbarColor['uid']);

foreach($treePages as $treepageUid) {

if ($navbarColor['uid'] == $treepageUid) {

$item = '#nav-item-'.(int)$treepageUid;

if ($navbarColor['tx_t3sbootstrap_navigationactivecolor']) {
$navbarColorCSS .= $item.'.active .nav-link{color:'.$navbarColor['tx_t3sbootstrap_navigationbgcolor'].' !important}';
}

} else {

$item = '.dropdown-item-'.(int)$treepageUid;

if ($navbarColor['tx_t3sbootstrap_navigationcolor']) {
$navbarColorCSS .= $item.'{color:'.$navbarColor['tx_t3sbootstrap_navigationcolor'].' !important}';
}
if ($navbarColor['tx_t3sbootstrap_navigationactivecolor']) {
$navbarColorCSS .= $item.'.active{color:'.$navbarColor['tx_t3sbootstrap_navigationactivecolor'].' !important}';
}
if ($navbarColor['tx_t3sbootstrap_navigationbgcolor']) {
$navbarColorCSS .= $item.'.active{background:'.$navbarColor['tx_t3sbootstrap_navigationbgcolor'].' !important}';
$navbarColorCSS .= $item.':hover,'.$item.':focus{background:'.$navbarColor['tx_t3sbootstrap_navigationbgcolor'].' !important}';
}
if ($navbarColor['tx_t3sbootstrap_navigationhover']) {
$navbarColorCSS .= $item.':hover,'.$item.':focus{color:'.$navbarColor['tx_t3sbootstrap_navigationhover'].' !important}';
$navbarColorCSS .= $item.'.active:hover,'.$item.'.active:focus{color:'.$navbarColor['tx_t3sbootstrap_navigationhover'].' !important}';
if (is_array($navbarColors)) {

foreach($navbarColors as $navbarColor) {

if (is_integer($navbarColor['uid'])) {

$treePages = $this->getTreePids($navbarColor['uid']);

foreach($treePages as $treepageUid) {

if ($navbarColor['uid'] == (int)$treepageUid) {

$item = '#nav-item-'.(int)$treepageUid;

if (!$contentObjectConfiguration['settings.']['navigationColor.']['nosubpages']) {
if ($navbarColor['tx_t3sbootstrap_navigationactivecolor']) {
$navbarColorCSS .= $item.'.active .nav-link{color:'.$navbarColor['tx_t3sbootstrap_navigationbgcolor'].' !important}';
}
}
if ($navbarColor['tx_t3sbootstrap_navigationcolor']) {
$navbarColorCSS .= $item.' .nav-link{color:'.$navbarColor['tx_t3sbootstrap_navigationcolor'].' !important}';
}

} else {

$item = '.dropdown-item-'.(int)$treepageUid;

if (!$contentObjectConfiguration['settings.']['navigationColor.']['nosubpages']) {
if ($navbarColor['tx_t3sbootstrap_navigationcolor']) {
$navbarColorCSS .= $item.'{color:'.$navbarColor['tx_t3sbootstrap_navigationcolor'].' !important}';
}
}

if ($navbarColor['tx_t3sbootstrap_navigationactivecolor']) {
$navbarColorCSS .= $item.'.active{color:'.$navbarColor['tx_t3sbootstrap_navigationactivecolor'].' !important}';
}
if ($navbarColor['tx_t3sbootstrap_navigationbgcolor']) {
$navbarColorCSS .= $item.'.active{background:'.$navbarColor['tx_t3sbootstrap_navigationbgcolor'].' !important}';
$navbarColorCSS .= $item.':hover,'.$item.':focus{background:'.$navbarColor['tx_t3sbootstrap_navigationbgcolor'].' !important}';
}
if ($navbarColor['tx_t3sbootstrap_navigationhover']) {
$navbarColorCSS .= $item.':hover,'.$item.':focus{color:'.$navbarColor['tx_t3sbootstrap_navigationhover'].' !important}';
$navbarColorCSS .= $item.'.active:hover,'.$item.'.active:focus{color:'.$navbarColor['tx_t3sbootstrap_navigationhover'].' !important}';
}
}
}
}
}

}

return $navbarColorCSS;
}

Expand Down

0 comments on commit 1c6d501

Please sign in to comment.