Drupal

Add an Edit Link in a Drupal View

Drupal Views have a Field Type called “Content: Edit link”.

Inside the view edit screen.

  1. Click the “Add” button in the Fields section
  2. Select “Content: Edit link”
  3. Enter “Text to Display”. If you leave this blank, the text “edit” will be displayed

Done. You now have a link to the edit screen.

Now lets make this look better

We can change the edit link into a gears icon with pull down “edit” when the mouse is moved over it. (Note: This really only makes sense when the “Format” is an “Unformatted List”.)

First we want to add some DIVs around the displayed elements so we can edit the styles.

Edit the field you just added.

  1. Under “Style Settings”, select “Customize field and label wrapper HTML”
  2. Set the “Wrapper HTML element” to “DIV”
  3. Select “Create a CSS class” and enter the text “contextual-links-region”

Also

  1. Under “Style Settings”, select “Customize field HTML”
  2. Set the “Wrapper HTML element” to “DIV”
  3. Select “Create a CSS class” and enter the text “contextual-links-wrapper”

Also

  1. Under “Rewrite Results”, select “Rewrite the output of this field”
  2. Enter the text

Also

  1. Under “No Results Behaviour”
  2. Select the “Hide is Empty” option

Leave a Reply