Hi all,
I have some troubles when using the block TopNavigationbar. I get an Error “Undefined variable $brandingText”.
I ve installed a fresh concrete cms 9.1.3 and use PHP Version 8.0.26. I use the atomik theme.
On my first page I put the block-type TopNavigationBar into the first global area.
In the block-options I choose:
Show pages in the navigation bar.
Enable transparent functionality
Enable sticky navigation bar
In branding-section I choose only “include logo” - without the branding text. The transparent logo I let empty. The normal logo was upload and selected.
I press the “add” Button and saved the block options.
I saved the changes on this site and published it.
If I go back to edit the site and want to edit the Block TopNavigationBar I get an error:
Undefined variable $brandingText
/concrete/blocks/top_navigation_bar/edit.php(61): Whoops\Exception\ErrorException->null
/concrete/blocks/top_navigation_bar/edit.php(61): Whoops\Run->handleError
/concrete/src/Block/View/BlockView.php(267): null->include
/concrete/src/View/AbstractView.php(164): Concrete\Core\Block\View\BlockView->renderViewContents
:
:
Has someone an idea how to solve this problem?
Thanks for your help
Trickler
donat
December 8, 2022, 1:57pm
#2
This seems like a php8 error at first. However i did not have an error after following your steps.
I was looking at the code and the brandingText (even if you do not want to use it) is set as $site->getSiteName.
So i guess you left your site name empty (during install) and need to fill it out even if you do not plan to display it in the top navigation.
EDIT: i was wrong. The site name has no effect if set or not. i guess it was just not done for php8 so if you want to patch it, replace the file at concrete/blocks/top_navigation_bar/edit.php with the following content:
<?php
defined('C5_EXECUTE') or die('Access Denied.');
/** @var \Concrete\Core\Form\Service\Form $form */
/** @var \Concrete\Core\Application\Service\FileManager $fileManager */
/** @var \Concrete\Core\Editor\EditorInterface $editor */
if ($includeBrandText && $includeBrandLogo) {
$brandingMode = 'logoText';
} else if ($includeBrandLogo) {
$brandingMode = 'logo';
} else {
$brandingMode = 'text';
}
?>
<div data-view="edit-top-navigation-bar-block">
<fieldset class="mb-3">
<div class="mb-3">
<legend><?=t('Options')?></legend>
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" id="includeNavigation" name="includeNavigation" value="1" v-model="includeNavigation">
<label class="form-check-label" for="includeNavigation"><?=t('Show pages in the navigation bar.')?></label>
</div>
<div class="form-check form-switch" v-if="includeNavigation">
<input type="checkbox" class="form-check-input" id="includeNavigationDropdowns" name="includeNavigationDropdowns" value="1" v-model="includeNavigationDropdowns">
<label class="form-check-label" for="includeNavigationDropdowns"><?=t('Include child pages in dropdown menus.')?></label>
</div>
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" id="includeTransparency" name="includeTransparency" value="1" v-model="includeTransparency">
<label class="form-check-label" for="includeTransparency"><?=t('Enable transparent functionality if the theme supports it.')?></label>
</div>
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" id="includeStickyNav" name="includeStickyNav" value="1" v-model="includeStickyNav">
<label class="form-check-label" for="includeStickyNav"><?=t('Enable sticky navigation bar on scroll if theme supports it.')?></label>
</div>
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" id="includeSearchInput" name="includeSearchInput" value="1" v-model="includeSearchInput">
<label class="form-check-label" for="includeSearchInput"><?=t('Display search input within navigation bar.')?></label>
</div>
</div>
</fieldset>
<fieldset class="mb-3 border-top pt-3">
<legend><?=t('Branding')?></legend>
<div class="mb-3">
<div class="form-check">
<input type="radio" class="form-check-input" id="brandingModeText" name="brandingMode" value="text" v-model="brandingMode">
<label class="form-check-label" for="brandingModeText"><?=t('Include Text Branding.')?></label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" id="brandingModeLogo" name="brandingMode" value="logo" v-model="brandingMode">
<label class="form-check-label" for="brandingModeLogo"><?=t('Include Logo.')?></label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" id="brandingModeLogoText" name="brandingMode" value="logoText" v-model="brandingMode">
<label class="form-check-label" for="brandingModeLogoText"><?=t('Include Text and Logo.')?></label>
</div>
</div>
<div class="mb-3" v-if="brandingMode == 'logoText' || brandingMode == 'text'">
<label class="form-label" for="logo"><?=t('Text Branding')?></label>
<input type="text" name="brandingText" class="form-control" value="<?=$brandingText ?? ''?>">
</div>
<div class="mb-3" v-if="brandingMode == 'logoText' || brandingMode == 'logo'">
<label class="form-label" for="brandingLogo"><?=t('Logo')?></label>
<concrete-file-input choose-text="<?=t('Choose Logo')?>" input-name="brandingLogo" file-id="<?=$brandingLogo?>"></concrete-file-input>
</div>
<div class="mb-3" v-if="includeTransparency && (brandingMode == 'logoText' || brandingMode == 'logo')">
<label class="form-label" for="brandingTransparentLogo"><?=t('Transparent Logo')?></label>
<concrete-file-input choose-text="<?=t('Choose Logo')?>" input-name="brandingTransparentLogo" file-id="<?=$brandingTransparentLogo?>"></concrete-file-input>
</div>
</fieldset>
<fieldset v-if="includeSearchInput" class="border-top pt-3">
<legend><?=t('Search')?></legend>
<div class="mb-3">
<label class="form-label" for="searchInputFormActionPageID"><?=t('Search Results Page')?></label>
<concrete-page-input choose-text="<?=t('Choose Page')?>" page-id="<?=$searchInputFormActionPageID ?? ''?>" input-name="searchInputFormActionPageID"></concrete-page-input>
</div>
</fieldset>
</div>
<script type="text/javascript">
Concrete.Vue.activateContext('cms', function (Vue, config) {
Vue.config.devtools = true;
new Vue({
el: 'div[data-view=edit-top-navigation-bar-block]',
components: config.components,
data: {
includeTransparency: <?=$includeTransparency ? 'true' : 'false'?>,
includeNavigation: <?=$includeNavigation ? 'true' : 'false'?>,
includeNavigationDropdowns: <?=$includeNavigationDropdowns ? 'true' : 'false'?>,
includeStickyNav: <?=$includeStickyNav ? 'true' : 'false'?>,
includeSearchInput: <?=$includeSearchInput ? 'true' : 'false'?>,
brandingLogo: <?=(int) $brandingLogo?>,
brandingTransparentLogo: <?=(int) $brandingTransparentLogo?>,
searchInputFormActionPageID: <?= isset($searchInputFormActionPageID) ? (int) $searchInputFormActionPageID : 0?>,
brandingMode: '<?=$brandingMode?>',
}
})
})
</script>
Hey donat, this works Thank you very much!!
axEllkr
December 10, 2022, 11:29am
#4
Addendum: now if you leave only the text version, without the logo, an error window also appears:
Undefined variable $brandingLogo
Details
/home/r/rr/new_site/public_html/concrete/blocks/top_navigation_bar/edit.php(94): Whoops\Exception\ErrorException->null
/home/r/rr/new_site/public_html/concrete/blocks/top_navigation_bar/edit.php(94): Whoops\Run->handleError
/home/r/rr/new_site/public_html/concrete/src/Block/View/BlockView.php(267): null->include
/home/r/rr/new_site/public_html/concrete/src/View/AbstractView.php(164): Concrete\Core\Block\View\BlockView->renderViewContents
axEllkr
December 10, 2022, 11:47am
#5
helped fix it like this: replace the file at concrete/blocks/top_navigation_bar/edit.php with the following content:
<?php
defined('C5_EXECUTE') or die('Access Denied.');
/** @var \Concrete\Core\Form\Service\Form $form */
/** @var \Concrete\Core\Application\Service\FileManager $fileManager */
/** @var \Concrete\Core\Editor\EditorInterface $editor */
if ($includeBrandText && $includeBrandLogo) {
$brandingMode = 'logoText';
} else if ($includeBrandLogo) {
$brandingMode = 'logo';
} else {
$brandingMode = 'text';
}
?>
<div data-view="edit-top-navigation-bar-block">
<fieldset class="mb-3">
<div class="mb-3">
<legend><?=t('Options')?></legend>
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" id="includeNavigation" name="includeNavigation" value="1" v-model="includeNavigation">
<label class="form-check-label" for="includeNavigation"><?=t('Show pages in the navigation bar.')?></label>
</div>
<div class="form-check form-switch" v-if="includeNavigation">
<input type="checkbox" class="form-check-input" id="includeNavigationDropdowns" name="includeNavigationDropdowns" value="1" v-model="includeNavigationDropdowns">
<label class="form-check-label" for="includeNavigationDropdowns"><?=t('Include child pages in dropdown menus.')?></label>
</div>
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" id="includeTransparency" name="includeTransparency" value="1" v-model="includeTransparency">
<label class="form-check-label" for="includeTransparency"><?=t('Enable transparent functionality if the theme supports it.')?></label>
</div>
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" id="includeStickyNav" name="includeStickyNav" value="1" v-model="includeStickyNav">
<label class="form-check-label" for="includeStickyNav"><?=t('Enable sticky navigation bar on scroll if theme supports it.')?></label>
</div>
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" id="includeSearchInput" name="includeSearchInput" value="1" v-model="includeSearchInput">
<label class="form-check-label" for="includeSearchInput"><?=t('Display search input within navigation bar.')?></label>
</div>
</div>
</fieldset>
<fieldset class="mb-3 border-top pt-3">
<legend><?=t('Branding')?></legend>
<div class="mb-3">
<div class="form-check">
<input type="radio" class="form-check-input" id="brandingModeText" name="brandingMode" value="text" v-model="brandingMode">
<label class="form-check-label" for="brandingModeText"><?=t('Include Text Branding.')?></label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" id="brandingModeLogo" name="brandingMode" value="logo" v-model="brandingMode">
<label class="form-check-label" for="brandingModeLogo"><?=t('Include Logo.')?></label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" id="brandingModeLogoText" name="brandingMode" value="logoText" v-model="brandingMode">
<label class="form-check-label" for="brandingModeLogoText"><?=t('Include Text and Logo.')?></label>
</div>
</div>
<div class="mb-3" v-if="brandingMode == 'logoText' || brandingMode == 'text'">
<label class="form-label" for="logo"><?=t('Text Branding')?></label>
<input type="text" name="brandingText" class="form-control" value="<?=$brandingText ?? ''?>">
</div>
<div class="mb-3" v-if="brandingMode == 'logoText' || brandingMode == 'logo'">
<label class="form-label" for="brandingLogo"><?=t('Logo')?></label>
<concrete-file-input choose-text="<?=t('Choose Logo')?>" input-name="brandingLogo" file-id="<?=$brandingLogo ?? ''?>"></concrete-file-input>
</div>
<div class="mb-3" v-if="includeTransparency && (brandingMode == 'logoText' || brandingMode == 'logo')">
<label class="form-label" for="brandingTransparentLogo"><?=t('Transparent Logo')?></label>
<concrete-file-input choose-text="<?=t('Choose Logo')?>" input-name="brandingTransparentLogo" file-id="<?=$brandingTransparentLogo ?? ''?>"></concrete-file-input>
</div>
</fieldset>
<fieldset v-if="includeSearchInput" class="border-top pt-3">
<legend><?=t('Search')?></legend>
<div class="mb-3">
<label class="form-label" for="searchInputFormActionPageID"><?=t('Search Results Page')?></label>
<concrete-page-input choose-text="<?=t('Choose Page')?>" page-id="<?=$searchInputFormActionPageID ?? ''?>" input-name="searchInputFormActionPageID"></concrete-page-input>
</div>
</fieldset>
</div>
<script type="text/javascript">
Concrete.Vue.activateContext('cms', function (Vue, config) {
Vue.config.devtools = true;
new Vue({
el: 'div[data-view=edit-top-navigation-bar-block]',
components: config.components,
data: {
includeTransparency: <?=$includeTransparency ? 'true' : 'false'?>,
includeNavigation: <?=$includeNavigation ? 'true' : 'false'?>,
includeNavigationDropdowns: <?=$includeNavigationDropdowns ? 'true' : 'false'?>,
includeStickyNav: <?=$includeStickyNav ? 'true' : 'false'?>,
includeSearchInput: <?=$includeSearchInput ? 'true' : 'false'?>,
brandingLogo: <?= isset($brandingLogo) ? (int) $brandingLogo: 0?>,
brandingTransparentLogo: <?= isset($brandingTransparentLogo) ? (int) $brandingTransparentLogo : 0?>,
searchInputFormActionPageID: <?= isset($searchInputFormActionPageID) ? (int) $searchInputFormActionPageID : 0?>,
brandingMode: '<?=$brandingMode?>',
}
})
})
</script>