YOOtheme Pro is here! The best WordPress and Joomla theme. Learn more

Avatar ben.kamp asked

Zoo router bug

When having a zoo item as the front page and typing in a url that doesn't exist consisting only of numbers a 404 is not given and the front page is displayed.

Ex: url.com/12345 shows the front page, url.com/12345x gives a 404

This is because com_zoo/router.php, line 333 states:
if (empty($vars)) {
if (($count == 0 || $count == 1 && is_numeric($segments[0])) && $menu_item = $app->menu->getActive()) {
$vars['task'] = @$menu_item->query['view'];

It looks like you left out a "=" on $menu_item = $app->menu->getActive(). It should be $menu_item == $app->menu->getActive() - that fixes it.

  • ZOO

3 Answers

0

Avatar michael.maass Support Online answered

This is because com_zoo/router.php, line 333 states:
if (empty($vars)) {
if (($count == 0 || $count == 1 && is_numeric($segments[0])) && $menu_item = $app->menu->getActive()) {
$vars['task'] = @$menu_item->query['view'];
It looks like you left out a "=" on $menu_item = $app->menu->getActive(). It should be $menu_item == $app->menu->getActive() - that fixes it.

I tried and could confirm the issue as well as your fix:

  • The menu item type of the Image "Home" menu item is ZOO > Item.

  • A URL url.com/12345 — where 12345 is not existing — does not trigger a 404 error but load the ZOO item. Once any letter is added to the wrong alias the 404 page is triggered correctly.

  • Changing line 334 of the file components/com_zoo/router.php from

    if (($count == 0 || $count == 1 && is_numeric($segments[0])) && $menu_item = $app->menu->getActive()) {
    

    to

    if (($count == 0 || $count == 1 && is_numeric($segments[0])) && $menu_item == $app->menu->getActive()) {
    

    fixes the issue.

I passed it on to the developers for revision.

Thanks for reporting and sharing your solution

0

Avatar hendrik Yootheme answered

Hi,

i've looked into this.

The provided fix does not solve the issue. It does only cause the if statement will never be true.
Assigning the active menu item to $menu_item is intended here. When you change this to a compare operator it will never be true.

We will need some more time to investigate this further.

Regards

0

Avatar ben.kamp answered

Agreed, I assumed it was a typo, but this was not correct as it broke pagination on a category list. What I've done now is left $menu_item = $app->menu->getActive() and then added a new case for 'item' and unset the $vars['task']. I'm not sure if this is best practice, but it does solve both the numeric 404s as well as the pagination.

case 'item':
unset($vars['task'])
break;

Know someone who can answer? Share a link to this question via email or twitter.