1

I have GeoJSON feed, created with a view in Drupal 7, that I want to filter on a path value in the url of the loaded page (/path/%). The feed is loaded as an Openlayers map on a page. The feed seem to work with its own feed-url and is not aware of the site url. Contextual filters in the view don't work either. I can use hook_views_query_alter or hook_views_pre_view. But I don't know how to bring the value from my path into the hook function. Any suggestions or example code snippets?

I currently have this, but the url seems to be not recognized. How can I bring that in?

function Mymodule_views_pre_view(&$view, &$display_id, &$args) {    
  if ($view->name == 'My_view' && $view->current_display == 'My_display') {
    $url = $_SERVER["REQUEST_URI"];
    $url_path = parse_url($url, PHP_URL_PATH);
    $basename = pathinfo($url_path, PATHINFO_BASENAME);
    $view->args[0] = $basename;
  }
}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.