0

A client wants to display different text in a page depending on the value of the View's Exposed Filter.

I could throw this logic into the template.php or use javascript (showing and hiding a span depending on the value), but this feels like a very poor way to do this when considering maintainability?

Does there exist a Views plugin to perhaps show different text blocks in the header based on the value of an exposed filter?

Currently on Drupal 7.31 using Better Exposed Filters. I'm open to using something other than Global: Text area if there is a better mechanism.

enter image description here

-1

You could use

hook_views_pre_render(&$view){
    $view->attachment_before = $view['exposed_input']['your_desired_field'];
}

Hope it works

  • I'm looking to add text to that area based on the value of the exposed filter. Would this be the appropriate hook to place a if (exp_Filter=='value') { $view->attachment_before .= 'Additional Text'; } ? – Rick Aug 28 '14 at 18:17
  • Yes, you can check the array 'exposed_input' with (you need the devel module installed and enabled) dpm($view['exposed_input']) to find out the key for your desired value. Then compare it to whatever condition through your if statement. – jojomojo Aug 28 '14 at 21:49
  • did you solve it? – jojomojo Sep 4 '14 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.