I currently have a glossary view set up using attachments in views using Drupal 7. I would like to have a header on top of the list of results displaying an element of the currently selected letter with a divider (top image). So far I've tried setting up a footer on the attachment but can't seem to figure a way to extract the current letter into the footer (bottom image).

This this.

I would like the view to look the same way the top image does. I've hardcoded the letter 'A' into the footer but am looking for a way to make it change with the letter selection.

1 Answer 1


You need to be able to perform business logic (php) in your Views header (or footer) to perform this task.

The Views header or footer should be able to accept PHP, just change the input filter to PHP. If that input filter is not available, you'll need to enable the PHP Filter module (core, optional) first.

Once you can use PHP in the Views attachment header or footer you can include logic to look at the selected glossary item such as:

$term = check_plain($_GET['glossary_term');
echo "<div id='selected-glossary-term'>" . $term . "</div>";

Then use whatever CSS you need in your theme or module to make this Letter appear however you wish.

  • Thank you. Is 'glossary_term' something Drupal will inherently recognize or would I have to replace that with something specific to my view? Perhaps the attachment name?
    – gussbus
    Jul 25, 2014 at 15:36
  • The glossary view should make a value on the url for the selected item. For instance with Views pagers it is page, for exposed filter fields under Settings you can pick the url values name ..... I assume the glossary view has a setting for this value, I dont have a glossary view sitting around to inspect.
    – tenken
    Jul 25, 2014 at 15:58

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.