drupaldrupal-7drupal-panelspathauto

Drupal Panel Pages Pathauto


I have a Panel Page set up with the path node/%node/foo and all works fine when I visit a link such as node/6/foo. However, when I visit nodealias/foo it doesn't work at all. Is it possible to get panels to work with pathauto in this way?

I am thinking I may have to implement the hook hook_url_inbound_alter and change the url myself.

I also posted a support request in the panels module here: http://drupal.org/node/1219796


Solution

  • I fixed this using the following code, you would need to alter the pattern to match the pattern of your url aliases and alter the function name to match your module's name.

    function brooklands_url_inbound_alter(&$path, $original_path, $path_language) {
        $pattern = '#^works\/[A-Za-z0-9]+(-[A-Za-z0-9]+)*\/images(\/\d+)?$#';
        if(preg_match($pattern, $original_path)) {
            $snip = substr($original_path, 0, strrpos($original_path, '/images'));
            $system_path = drupal_lookup_path('source', $snip);
            if($system_path) {
                $tail = substr($original_path, strrpos($original_path, '/images'));
                $path = $system_path . $tail;
            }
        }
    }