1

I have a View that has a filter which allows users to select nodes that contain specific taxonomy terms.

I would like to display this as a HTML list of links (<ul>). How can I do this?


Steps I have tried

1. Using Better Exposed filters

This displays a filter as links. But the links are displayed wrapped in <Div> tags instead of a UL tag.

2. Using Views template

Using views-exposed-form.tpl.php lets you access the exposed form, but it doesn't let you access the actual widget the makes up the filter.

3. Using Custom Code

This page says you can turn a select list into links via a custom module. But it requires Javascript to make the links work, which seems bad practise to me

1 Answer 1

0

I would also go for step 3 and you really need JS for that option. Another option is, structure the links as it looks when you do a search like so..

// Merge the option name or key into the link
$link = "your-view?category=" . $select_option;
// Create the link
$somearrayforULlist[] = l($select_option, $link);

So when you click one of the links, it would reload the page and your view will use the filter values in the URL in your form.

enter image description here

2
  • Where would I put that code?
    – big_smile
    Commented Apr 1, 2015 at 18:13
  • The same function in the link you posted in Step 3, hook_form_alter specifically targeting your View filter form. Commented Apr 2, 2015 at 2:30

Your Answer

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

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