I have created a view to display slideshow from specific content type.

Now I have a condition that if visitor is new then slideshow will sort according to custom field "slider order". And if user visited already then slideshow will sort according to post date.

I have tried this from "hook_views_query_alter" but I want this to be done from view only.

I applied some custom sorting in views but not working (actually I have no idea about custom sorting in views)

Please let me know the conditions.

Fields: title, description, Image

Filter: content type= slider

Sorting: Post date (desc) [here I need your help]

1 Answer 1

  • For any field you want to pull a value from a Cookie you add an exposed filter, here I add a contextual filter for the field, here a node->title:

    enter image description here

  • Then we configure the filter to pull a value from the URL. If none is provided we define how to find the value via PHP code. This is the secret to pulling the value from a $_COOKIE value.

enter image description here

  • Then we supply a blurb of code to read the Cookie value:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.