I have a views table that displays a pdf attachment by a icon that links to the file.

My question is:
If the pdf is not attached to that node (ie the field is empty), what is the easiest way to instead display a link to a popup form- where the user could upload a pdf attachment to that node?

Sorry- this should be rather simple but I am thinking there was an easy way to do this!

Comments

MM10’s picture

If this helps anyone, I figured this out.

I added a 'pdf attachment' field, excluded it from the display, rewrote the output of the field to a pdf icon image, gave it an empty text value of 'upload', and then check the 'Hide if empty' field. In addition, I added the Node ID: nid field, and also excluded it from the display.

To create the viewable field in the table, I added a Node: Edit link field, rewrote the output of the field to refer to the above 'pdf attachment field' token, and outputted the field as a link, using a path containing the nid token: /node/[nid]/edit. This allowed me to display an upload link to the node if it was empty. Otherwise, a pdf icon appears if there is already an uploaded pdf in the pdf attachment field.

To make the popup, I simply downloaded the Popup API module, giving me a popups class that I could add to the view path containing the nid token: /node/[nid]/edit field above.

Hope this makes sense to anyone else needing to generate a table that has a user interactive nature.