iomgi
iomgi

Reputation: 1

Drupal view listing with glossary AND an additional contextual filter

Context:

I have a view, with a page listing my all articles. I have added an attachment to that view in order to add a glossary (a to z) on the top of the listing to facilitate the search. > method used <

That works fine.

My problem is:

I want to add another contextual filter to filter my article by user, and so should be the glossary attachement. But if I turn "Inherit contextual filters" to "yes" it breaks the glossary process as soon as I select a letter as the glossary will inherit from the letter filter too and so show matching articles instead of exposing the contextual filter.

I am looking for any kind of solution: configuration, modules, hook, ...

It is a very specific problem, I hope I was clear enough

Thank you for reading me.

Upvotes: 0

Views: 469

Answers (1)

iomgi
iomgi

Reputation: 1

Ok I will reply to myself with a fix, don't know if it the best way but it works for me.

Using a hook:

Keep "Inherit contextual filters" to "yes". Add the following bits of code (in a custom module) in order to deny access to the unwanted contextual filter.

function HOOK_views_pre_view(&$view, &$display_id, &$args) {
  if($view->name == "VIEW_NAME" && $display_id == "ATTACHMENT_ID") {
    if(isset($args[1])) unset($args[1]);
  }
}

I stay tuned for any better alternatives.

Upvotes: 0

Related Questions