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
Show all sites item only if multi sites is enabled #14936
Conversation
Is the issue fixed or still available to work on it? |
The issue should be fixed afterwards. |
@@ -751,6 +751,7 @@ protected function setBasicVariablesNoneAdminView($view) | |||
|
|||
$pluginManager = Plugin\Manager::getInstance(); | |||
$view->relativePluginWebDirs = (object) $pluginManager->getWebRootDirectoriesForCustomPluginDirs(); | |||
$view->isMultiSitesEnabled = Manager::getInstance()->isPluginActivated('MultiSites'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure you've got a boolean value:
$view->isMultiSitesEnabled = (bool)Manager::getInstance()->isPluginActivated('MultiSites');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw the method always returns a bool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OKay. So the (bool)
is not necessary.
@@ -1,3 +1,3 @@ | |||
<div class="top_bar_sites_selector piwikTopControl"> | |||
<div piwik-siteselector show-selected-site="true" class="sites_autocomplete"></div> | |||
<div piwik-siteselector show-selected-site="true" show-all-sites-item="{{ (isMultiSitesEnabled|default) ? 'true' : 'false' }}" class="sites_autocomplete"></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...and the default filter won't be necessary:
<div
class="sites_autocomplete"
piwik-siteselector show-selected-site="true"
show-all-sites-item="{{ isMultiSitesEnabled ? 'true' : 'false' }}">
</div>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the default
in there as I couldn't guarantee the basic variables
method in the controller is always called so just wanted to be sure to not break anything. I could remove it as it's likely not needed. It just means if someone did like $view = new View('...'); $view->render()
without calling the basic variables in the controller then things could break when embedding that template. From what I see it shouldn't be needed though. Will check again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can see it can be removed indeed cheers 👍 will wait for the tests to confirm it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! :)
To prevent showing a not working link to the all sites page.
There are a few more usages of siteselector but they aren't as important and visible for now. Also sometimes I think they don't link to the all sites page but handle it differently.