Hướng dẫn sử dụng Entityqueue with Views trong Drupal 7

Hướng dẫn sử dụng Entityqueue with Views trong Drupal 7

>> Sử dụng Drupal Entityforms tốt hơn Drupal Webform?

>> Lưu ý khi sử dụng $query->fetchAll() (hint: it's optional) trong Drupal 7

>> Có thể thay đổi Menu Item Visibility module với custom "in code"

Last time I gave a quick introduction on how to create and manage queues using Entityqueue. This time I'll show you how to use them with Views to display content sorted by their position in the queue.

First create your view like you normally would. The screenshots in this example, we are using a view of Content (aka Nodes), but this should be the same process for any entity type.

Then click add in the "Relationships" section. Select the Entityqueue relationship handler.

Hướng dẫn sử dụng Entityqueue with Views trong Drupal 7

Just like with Nodequeue you can (and usually should) check the "Limit to one or more queues" box. Then check the box(es) for your queue(s) from the list. Most of the time when I need a queue, the client wants a list of content, probably sorted by most recent at the top. But they also want to be able to feature a few other items at the top for a period of time. In order to accomplish that, the queue will hold the featured items, and items in the queue will show at the top, followed by the normal sorting rules. In our view we will leave the "Require this relationship" checkbox unchecked.

You can see in the preview that the results aren't sorted properly, yet.

Click add in the "Sort criteria" section. Select the Queue Position and Queue Name sort handlers.

Set Queue Position to "Sort ascending" so that the first item in the queue will show up first in the view results.

Since we didn't check the "Require this relationship" checkbox, we need to also sort by the Queue name and select "Sort descending". The way this works is that if the node is not in the queue, the Queue name will be empty, as will the position. Since the position is a numeric handler, empty gets treated as 0, and ends up first in the list.

We will counteract this by sorting by the Queue Name first, and sort them descending so that items in the queue show first followed by items that aren't in the queue. Rearrange the sort criteria so that Queue Name is first, followed by Queue Position, then add any other sort criteria you have. Now you should see your results sorted properly.

 

 

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Khanh Hoang

Khanh Hoang - Kenn

Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.

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

 
Sử dụng Repeater field trong Wordpress Custom field

Sử dụng Repeater field trong Wordpress Custom field

Repeater Fields: Define the sub fields which will appear as cells in the repeater table (see screenshot above)

15 sản phẩm “hot” đáng chờ tại CES 2012

15 sản phẩm “hot” đáng chờ tại CES 2012

Nhiều sản phẩm "đáng mặt anh tài" sẽ xuất hiện tại Triển lãm Điện tử tiêu dùng 2012, Las Vegas, Mỹ dựa theo những tin đồn, thông tin rò rỉ trước trước sự kiện.

Triển lãm Palme Việt Nam về thiết bị nghe - nhìn, âm thanh, ánh sáng...

Triển lãm Quốc tế lần thứ 3 tại Việt Nam về Thiết bị Nghe – Nhìn, Âm thanh – Ánh sáng chuyên nghiệp, Truyền hình, Tích hợp hệ thống và Công nghệ giải trí sẽ trở lại Thành phố Hồ Chí Minh sau một năm vắng bóng.

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

 

Diet con trung