Closed Saboteur777 closed 3 years ago
Are you able to provide the URL (relative) that you're on when this code runs? There is already code in place that determines if the node URL is in the current URL - which your PR to add over the top of this check.
Depending on the depth of the node/URL you may need to include checking against children:
{{ craft.navigation.getActiveNode({ handle: 'topMenu' }, true) }}
You can see a screen recording about this: https://drive.google.com/file/d/1UUhxnjYLHnVehSVBEvSFRnOEjBDpVl6T/view?usp=sharing
something
, children URLs are something/...
.true
.Lines 681-686 seems to behave a little strange for me - if that's the piece of code you mentioned, then it is not working correctly. I have added a couple of debugging statements to the code before those lines:
if ($includeChildren) {
// Then, provide a helper based purely on the URL structure.
// /example-page and /example-page/nested-page should both be active, even if both aren't nodes.
// Include trailing slashes to check if the parent has a child, otherwise we get partial matches
// for things like /some-entry and /some-entry-title - both would incorrectly match
var_dump('Current URL: ' . $currentUrl, 'Node URL: ' . $nodeUrl, 'Node URL with /: ' . $nodeUrl . '/');
var_dump('strlen: ' . strlen($nodeUrl . '/'), 'substr($currentUrl, 0, strlen($nodeUrl . "/")): ' . substr($currentUrl, 0, strlen($nodeUrl . '/')), 'substr($currentUrl, 0, strlen($nodeUrl . "/")) === $nodeUrl . "/" : ' . substr($currentUrl, 0, strlen($nodeUrl . '/')) === $nodeUrl . '/');
var_dump('==== # ====');
if (substr($currentUrl, 0, strlen($nodeUrl . '/')) === $nodeUrl . '/') {
// Make sure we're not on the homepage (unless this node is for the homepage)
if ($nodeUrl !== $siteUrl) {
$isActive = true;
}
}
// If `$currentUrl` string contains `$nodeUrl` string, an integer is returned - if this happens,
// a match is found.
if (is_int(strpos($currentUrl, $nodeUrl))) {
// $isActive = true;
}
}
This is the output:
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: home' (length=14)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: home/' (length=22)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 5' (length=9)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http:' (length=53)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: dogs' (length=14)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: dogs/' (length=22)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 5' (length=9)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http:' (length=53)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: dogs/shelter-seekers' (length=30)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: dogs/shelter-seekers/' (length=38)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 21' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.localho' (length=69)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: dogs/packs' (length=20)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: dogs/packs/' (length=28)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 11' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizl' (length=59)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: dogs/breeds' (length=21)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: dogs/breeds/' (length=29)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 12' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizli' (length=60)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: reports' (length=17)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: reports/' (length=25)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 8' (length=9)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://w' (length=56)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: reports/dog-in-trouble' (length=32)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: reports/dog-in-trouble/' (length=40)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 23' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.localhost' (length=71)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: requests' (length=18)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: requests/' (length=26)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 9' (length=9)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wi' (length=57)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: requests/hitchhikes' (length=29)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: requests/hitchhikes/' (length=37)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 20' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.localh' (length=68)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: professionals' (length=23)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: professionals/' (length=31)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 14' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.' (length=62)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: professionals/accomodation' (length=36)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: professionals/accomodation/' (length=44)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 27' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.localhost:300' (length=75)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: professionals/breeders' (length=32)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: professionals/breeders/' (length=40)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 23' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.localhost' (length=71)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: professionals/kennels' (length=31)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: professionals/kennels/' (length=39)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 22' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.localhos' (length=70)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: professionals/photographers' (length=37)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: professionals/photographers/' (length=45)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 28' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.localhost:3000' (length=76)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: professionals/vets' (length=28)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: professionals/vets/' (length=36)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 19' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.local' (length=67)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: foundations' (length=21)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: foundations/' (length=29)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 12' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizli' (length=60)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: foundations/health' (length=28)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: foundations/health/' (length=36)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 19' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.local' (length=67)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: foundations/animal-rescue' (length=35)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: foundations/animal-rescue/' (length=43)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 26' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.localhost:30' (length=74)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: foundations/on-the-road' (length=33)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: foundations/on-the-road/' (length=41)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 24' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.localhost:' (length=72)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: events' (length=16)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: events/' (length=24)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 7' (length=9)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://' (length=55)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: read' (length=14)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: read/' (length=22)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 5' (length=9)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http:' (length=53)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: read/good-to-know' (length=27)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: read/good-to-know/' (length=35)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 18' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.loca' (length=66)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: read/news' (length=19)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: read/news/' (length=27)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 10' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wiz' (length=58)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: settings' (length=18)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: settings/' (length=26)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 9' (length=9)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wi' (length=57)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: settings/general' (length=26)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: settings/general/' (length=34)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 17' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.loc' (length=65)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: settings/personal' (length=27)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: settings/personal/' (length=35)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 18' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.loca' (length=66)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: settings/authentication' (length=33)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: settings/authentication/' (length=41)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 24' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.localhost:' (length=72)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: settings/notifications' (length=32)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: settings/notifications/' (length=40)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 23' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.localhost' (length=71)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Current URL: http://wizlie.localhost:3000/settings' (length=50)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL: settings/privacy' (length=26)
/var/www/vendor/verbb/navigation/src/elements/Node.php:681:string 'Node URL with /: settings/privacy/' (length=34)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'strlen: 17' (length=10)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:string 'substr($currentUrl, 0, strlen($nodeUrl . "/")): http://wizlie.loc' (length=65)
/var/www/vendor/verbb/navigation/src/elements/Node.php:682:boolean false
/var/www/vendor/verbb/navigation/src/elements/Node.php:683:string '==== # ====' (length=11)
As you can see, the substr($currentUrl, 0, strlen($nodeUrl . '/')
part returns strange values and they will never be equal to $nodeUrl . '/'
, so
// Make sure we're not on the homepage (unless this node is for the homepage)
if ($nodeUrl !== $siteUrl) {
$isActive = true;
}
will never be run.
Thanks for the info - I've not tested with a site URL like wizlie.localhost:3000
. I assume the base URL of your site is set to this?
The reason I'm being so guarded against changes to this function is we've had a lot of issues with all sorts of multi-site setups, that've taken a good while to get right. I just want to ensure I can replicate your setup correctly.
I'll do some further testing and get back to you.
Yes, that's the base URL. If you are interested, I can give you access to the private repository on GitLab, or send over a DB backup to you - this way you can reproduce the exact setup.
I understand your hesitation, this seemed a pretty core method, I was also reluctant changing it.
(This is a multi-site config, btw.)
If you're on the Craft Discord, feel free to DM me (crawf), or reach out to support@verbb.io
as a copy of your setup might be handy just in case I can't replicate it.
Thanks - sent the DB dump on Discord.
Description
Trying to use
getActiveNode()
, but it does not seem to work. Current template code:{{ dump(activeNode) }}
returnsnull
. The type of the node is custom, it is referencing a URL (which is routed to the correct template byconfig/routes.php
).Additional info