Comments (13)
Yeah, that makes sense — if it's a string, the first condition is false, so it will evaluate the second condition. If it was completely empty, it wouldn't. Your isset
solution is the way to go here...
from processwire-dashboard.
Mmh. Not sure. The if statement would just skip the second part if the first part is true.
Can you post how you're setting up the panel itself, what you're passing into the 'shortcuts' option?
from processwire-dashboard.
Sure :)
Heres my code:
$allshortcuts[] = "";
$allshortcuts['Plan erstellen'] = [$this->config->urls->admin.'page/add/?parent_id=1024&template_id=47', 'calendar', 'Einen neuen Plan erstellen.'];
$allshortcuts['News eintragen'] = [$this->config->urls->admin.'page/add/?parent_id=1023&template_id=45', 'newspaper-o', 'Hier kann ein neuer News Eintrag erstellt werden.'];
$allshortcuts['User syncronisieren'] = [$this->config->urls->admin . 'setup/syncuser/', 'refresh', 'User akutalisieren.'];
$allshortcuts['Updates'] = [$this->config->urls->admin . 'setup/upgrades/', 'download', 'Systemupdates suchen und installieren.'];
$allshortcuts['Einstellungen'] = [$this->config->urls->admin . 'page/edit/?id=' . $this->pages->get("/verwaltung/einstellungen/")->id, 'cogs', 'Hier können die Einstellungen geändert werden.'];
$allshortcuts['Alle Seiten'] = ['/ugs/page/', 'files-o', 'Alle vorhandenen Seiten anzeigen.'];
$panels->add([
'panel' => 'shortcuts',
'title' => 'Menü',
'data' => [
'shortcuts' => $allshortcuts,
'display' => 'list',
'fallbackIcon' => 'star-o',
'checkAccess' => true
]
]);
from processwire-dashboard.
The if statement would just skip the second part if the first part is true.
Only if AND is used but no OR, I guess, so
if (!$page || !isset($page->url)) {
should be needed perhaps?
from processwire-dashboard.
BTW, I get the same PHP Notice, so it an issue. I modifed the code as I showed above, it work for me with isset().
https://stackoverflow.com/questions/8138269/multiple-boolean-conditions-operator-precedence
"&& depends of the evaluation of the right expression when left one is true, || doesn't."
from processwire-dashboard.
$page
is not an object in this case, so it does exist but doesn't allow property access. @szabeszg's fix should work. I'll try and plug the example config into my test setup to see why $page
is not an object in the first place.
from processwire-dashboard.
I don't think this is about faulty boolean logic. If $page
is empty, the first condition !$page
is already true
so it won't evaluate the second condition since true || [anything]
will always be true
.
from processwire-dashboard.
If
$page
is empty, the first condition!$page
is alreadytrue
so it won't evaluate the second condition sincetrue || [anything]
will always betrue
.
Apparently it does evaluate the second one...
from processwire-dashboard.
Looks like it fails when $page is a string like: '/admin/page/edit/?id=1'
from processwire-dashboard.
Just for reference here is the line in question:
Why would a string find it's way to that line? While isset() would work wouldn't it be better to ensure that $page is a Page object at the very top?
from processwire-dashboard.
eg this (but I don't know how your module works exactly and what syntax you expect...):
if(is_string($page)) $page = $this->wire->pages->get($page);
from processwire-dashboard.
The string just means it's already a URL. So yeah, I should go with an additional is_object
or is_a
and then isset
. Better safe than sorry.
from processwire-dashboard.
Fixed in 1.5.2, thanks everybody for reporting and helping troubleshoot!
from processwire-dashboard.
Related Issues (12)
- Fatal Error: Uncaught Error: Class 'NumberFormatter' not found in DashboardPanelNumber.module:43 HOT 2
- Spacing tweak for Page List panel HOT 4
- PHP Notice: Undefined variable: trend in .../Dashboard/views/panels/number.php:1 HOT 1
- Multisite problem: Dashboard: Filename "" is not in an allowed path. HOT 11
- Notice: Undefined variable: content in ..\Dashboard\views\panel.php on line 22 (if empty) HOT 1
- PHP Warning: setlocale() expects parameter 1 to be int, string given in DashboardPanelNumber.module:98 HOT 1
- Conflict with TracyDebugger HOT 6
- Missing Edit-Icon in DashboardPanelCollection.module HOT 5
- Redirect issue after deleting pages from trash HOT 1
- PHP 8.2 deprecations HOT 3
- PHP-8.1-related deprecation warning HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from processwire-dashboard.