views:

2040

answers:

3

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?

+3  A: 

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]
jhedstrom
Thank you! That's genius! :-)
RD
A: 

Thank ou so much !

A: 

Hi jhedstrom (and others that might know the solution)

I have done the first step, adding the Node: Edit Link to my view and its perfect.

my problem is, that I cant get the permissions right. My users has to be able to see this "edit" link and they cant. and they are NOT allowed to edit the view, only the content inside the view.

I do have the permissions set so they can edit everything, so I don't understand why they cant see the link. The edit link on normal nodes are visible to them, so this should too right?

I know this is an old thread, but there must be a solution out there..

Any suggestions?

Duddimai

related questions