Score:1

Filter GeoJSON feed on a value in the path

ca flag

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;
  }
}
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.