Entity Views Attach: sử dụng cho hầu hết Views trong Drupal 7

Entity Views Attach: sử dụng cho hầu hết Views trong Drupal 7

Entity Views Attach (EVA) is a wonderfully useful Drupal module which makes Views more powerful.Entity Views Attach: sử dụng cho hầu hết Views trong Drupal 7

EVA allows you to automatically attach any view to content, comments or terms.

We're going to show you 2 examples of EVA in use. Both of them solve problems that were asked by our members this week.

First, we'll see how to sort terms however we want and then we'll see how to add an image for a file download link.

Example #1: Sort taxonomy terms

You can download EVA from https://drupal.org/project/eva.

Here's the first problem we face. We don't have any way to contol the order of our taxonomy terms. Our training member wanted to take control of the ordering and sort these terms alphabetically.

media_1389133598566.png

Let's go and create a view that will sort our terms.

  • Go to Structure > Views > Add New View
  • Choose to show "Taxonomy terms" and then select the terms you want to show. In this example, we'll show "Tags".
  • Choose the Display format you want, but you must choose to show fields.
  • Click Continue and edit.

media_1389132814072.png

  • At the top of the Views screen, click Add and then choose EVA Field.

media_1389133131369.png

  • You will now see a new area of Views called "Entity Content Settings":

media_1389133169834.png

  • Click Entity Type and choose where you want to attach this View to. In our example, we chose "Node".

It's worthing noting that you can also use EVA to attach Views to Comments, Terms or users. For example, you might want create a View showing the content that a user has created and show it on their profile. In that instance, you would choose "User".

media_1389133193568.png

  • Click Bundles and choose which content type you want to attach this View to. In our example, we choose "Article".

media_1389133441656.png

Finally, we need to make sure that EVA will only pull in the terms that have been added to the content we're looking at. Otherwise, we'd end up with a very long list.

  • Under Advanced, click Add next to Relationships.
  • Check the box "Taxonomy term: Content with term" and then on the next screen, check "Require this relationship".

media_1389194589478.png

You are now free to create the view as you wish. Here's one change we need for our example:

  • Under Sort Criteria, choose to sort the view how you wish. In this example, we choose "Taxonomy term" and "Sort ascending".

media_1389133543745.png

  • Save the view.
  • Visit any article on your site with terms and you'll see that your new view has been attached:

media_1389133576686.png

If you want to remove the original Tags field, go to Structure > Content types > Manage Display and move the "Tags" field to the "Hidden" area:

media_1389134060194.png

Example #2: Changing a download link into an image

Here's an alternate example of EVA in action. In this example, our member wanted to change a file name into a "Download image".

We've shown how to do this before with Display Suite. Now we'll show how do it with EVA. The image below shows the problem - the file name is showing instead of a download button that we can style.

media_1389134017895.png

  • Go to Structure > Views > Add New View
  • Choose to show an "Unformatted list" of "fields"

media_1389135263579.png

  • Click Add > EVA Field
  • Click to add a new field and choose "File: Path"

media_1389136150279.png

  • Check "Display download path instead of file storage URL"

media_1389136227861.png

  • Check the box for the "REWRITE RESULTS" area.
  • In the Text area, use HTML to show an image and a link. We can use the Replacement patterns to automatically insert the URL with [field_file]. To do this, you will need to know the URL to the image, which in this example is http://bit.ly/19ZE2db.

media_1389134438655.png

  • Look under "Entity Content Settings", Click Entity Type and choose where you want to attach this View to.
  • Click Bundles and choose which content type you want to attach this View to.

media_1389134476360.png

We now need to add both a Contextual Filter and a Relationship.

  • Contextual Filter: select "Content: NID"
  • Relationship: select "Content: File". Make sure to check the "Require this relationship" box.

media_1389136344829.png

That should complete the process and the image will show. Click on it and you'll download the file.

 

Bạn thấy bài viết này như thế nào?: 
No votes yet

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
7 việc cần để bắt đầu với lĩnh vực Big Data/Analytic

7 việc cần để bắt đầu với lĩnh vực Big Data/Analytic

Khoan hãy nói về các mục tiêu khác, việc đầu tiên là bạn phải thu thập dữ liệu cái đã. Công việc này nghe có vẻ dễ dàng nhưng cực kỳ quan trọng

LG Optimus 3D Phone Review, a Magical Allure of 3D

LG Optimus 3D Phone Review, a Magical Allure of 3D

Introduction of 4G was a thrill in the world and people were passionate about implementing this technology in their daily lives.

Apple sẽ sử dụng camera 3D lên các sản phẩm tiếp theo

Apple sẽ sử dụng camera 3D lên các sản phẩm tiếp theo

Apple có thể đang trong quá trình chuẩn bị để mang camera 3D lên các thiết bị tiếp theo của hãng.

Công ty diệt chuột T&C

 

Diet con trung