? views404-798550.patch Index: views404.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views404/views404.module,v retrieving revision 1.1.2.2 diff -u -p -r1.1.2.2 views404.module --- views404.module 13 May 2010 20:34:29 -0000 1.1.2.2 +++ views404.module 14 May 2010 02:06:43 -0000 @@ -14,28 +14,46 @@ function views404_views_pre_view(&$view) if (!empty($path)) { $path_array = explode('/', $path); $args = array_filter(arg()); + $matched = array_intersect($path_array, $args); + $conflicting_in_view = array_diff($path_array, $matched); + $conflicting_in_args = array_diff($args, $matched); + $view_arguments = $view->display_handler->options['arguments']; - // Debug output - //drupal_set_message($view->name . ' ' . $view->display_handler->display->id . '
' . $path . '
' . implode('/', $args)); + // Return if view is embeded + if (count($matched) == 0) { + return; + } + + // Add in % for each argument, as needed + if (count($view_arguments) > 0) { + foreach ($view_arguments as $type => $data) { + if (count($conflicting_in_view) < count($conflicting_in_args)) { + $path_array[] = '%'; + // Re init varables to take into account the % in the path + $path = implode('/', $path_array); + $matched = array_intersect($path_array, $args); + $conflicting_in_view = array_diff($path_array, $matched); + $conflicting_in_args = array_diff($args, $matched); + } + } + } - // Logic for sending a 404 - // if the argument count and the view path count are not the same, - // (frontpage VS frontpage/BadPath) - // and there was a match on the view path and the argument. (!embeded view) - // (frontpage VS node/page/add) - if ( count($args) !== count($path_array) - && count(array_intersect($path_array, $args)) > 0 - ) { - watchdog('views404', t('View path: !path
Path given: !args
Matched: !match
Was Looking for: !looking
Got this instead: !got', array( - '!path' => $path, - '!args' => implode('/', $args), - '!match' => implode('/', array_intersect($path_array, $args)), - '!looking' => implode('/', array_diff($path_array, $args)), - '!got' => implode('/', array_diff($args, $path_array)), - ) - )); - drupal_not_found(); - exit(); + // Return if parameter count matches + if (count($conflicting_in_view) == count($conflicting_in_args)) { + return; } + + // If we got this far, odds are this is a 404 + watchdog('views404', t('View path: !path
Path given: !args
Matched: !match
Was Looking for: !looking
Got this instead: !got
Number of view arguments: !viewarg', array( + '!path' => $path, + '!args' => implode('/', $args), + '!match' => implode('/', $matched), + '!looking' => implode('/', $conflicting_in_view), + '!got' => implode('/', $conflicting_in_args), + '!viewarg' => count($view_arguments), + ) + )); + drupal_not_found(); + exit(); } }