views:

129

answers:

3

Drupal Question:

Does anyone have a method of using Views and highlighting a selected/current node.

So for example:

I have a list of articles under a heading:

2009 Articles

Dog Training

Cat Cleaning

Snake Wrangling

The 3 articles are made from the view (ie: latest articles from 2009)... as the user makes new articles, they are automatically added into this view by title.

I now need to find a way, that if a user clicks on say CAT CLEANING.... and the cat cleaning article appears, the CAT CLEANING in the view becomes bold (or some CSS indication it's the current article.)

I know this is pretty easy with MENU's, But I don't want to force a user to add new articles into a menu.

Thanks alot, JD

+1  A: 

You could override whichever Views template you're using (do this by clicking the Theme: Information link on the View editing page), and basically say "if the link to this node is the same as the currently viewed path, then add a 'current' class to it."

Mike Crittenden
+1  A: 

Here is what you need to do:

  1. Look up the class of the view list item (e.g. Dog training) using Firebug
  2. Add CSS for the view list item manually in the theme folder or using something more convenient like the css injector module
  3. The CSS will be something like this

    .view-name .view-name-of-field-here a:active {text-decoration: underline; color: red}

Here we are using the "active" CSS pseudo class to color and underline the link if the URL in the view list item is the same URL as the web page.

Sid NoParrots
A: 

hi mike. Your solution sounds interesting. would like to try it out. Can you provide a more detailed answer?

Is it possible to cross-check the nid as well and print a class if true?

Stefan