Drupal Views: Adding Edit button and other buttons per item
You can add links and then style them as buttons (if you really need it to look like a button) by doing something like this:
Add the following fields to your view:
- Node: Edit Link (this will take care of permissions for you, only displaying a link for users that have access to edit)
- Node: Nid
In order to get that second field to be an arbitrary link containing the node ID, select the Output this field as a link option when configuring the field. In the Link path box, enter the desired link, something like this:
action/[nid]
or, you can use an absolute url
http://www.example.com/action/[nid]
rockstardev
Updated on June 04, 2022Comments
-
rockstardev almost 2 years
I've setup a view in drupal that lists items like this:
IMAGE 1 | IMAGE 2 | IMAGE 3 | IMAGE 4 desc | desc | desc | desc
where "desc" is, you guessed it, a description of the node. What I need is to end up with something like this:
IMAGE 1 | IMAGE 2 | IMAGE 3 | IMAGE 4 desc | desc | desc | desc EDIT | EDIT | EDIT | EDIT ACTION | ACTION | ACTION | ACTION
Where EDIT goes to the edit page of the various nodes. Also, the ACTION signifies a button that I want to appear underneath the items that navigates to a page, let's call it http://www.mysite.com/action and takes the id as a parameter to end up with something like this: http://www.mysite.com/action/1.
I hope this all makes sense.
The pain in the ass way to solving this is to create a theme file views-view-NAME.tpl.php and manipulate the $rows variable. I just think there must be a better way and I'm obviously just missing something.
So, does anybody know how to do this?