HOW TO CREATE A DYNAMIC PORTFOLIO PAGE USING ONLY VIEWS IN DRUPAL7?

Today I gonna show you how to link an image field with a link field exists in a same node using views dynamically. Sounds confusing, ok I will give a brief explanation about the situation.

Lets say that you have a content type called "Portfolio" which has a "title field", "taxonomy field", "image field", "link field" and a body field which shows all your latest works. Now whenever you add your latest works in the site it only displays as full node view or teaser view. But you want few custom displays like a block with image and title only which links to the full node or the external URL (using custom link field). Can you do that without writing complex codes, YES, YOU CAN! use VIEWS module.

Content type fieds

CREATE VIEWS

  • Go to /admin/structure/views and create a new view
  • Select your content type (in my case "Portfolio")
  • Uncheck the page display & block display and click the "Continue & edit" button" which will take you to the master display of the views

Create new view

At the Master display you can give a title name for the view and format style

In the field sections you can see already "title" field is added by the views module so we just need to add "Link field" and "Image Field" only.

Now here comes the tricky part first lets add "link field" in the configurations "uncheck the label" so that the label is hidden and select the "Exclude from display" check box, so that the output of the field is hidden

Link field views configuration

Next lets add image field and at the configurations section "uncheck the label"  so that the label is hidden and make sure that the image link is set to nothing. Next click "REWRITE RESULTS" and select the check box "output this field as a link.  And in the link path field add the url field we have hidden just before. (if you scroll down little more you can see the replacebale patterns (if you have installed "TOKEN" module just click on the link pattern to enable.) That's it, now our image is linked to the custom URL we have created. NOTE: MAKE SURE THAT THE LINK FIELD IS ABOVE THE IMAGE FIELD"

Image field views configuration

Dynamic portfolio configuration using only drupal views module.

Now we can create a block view or page view.

Views Page Display