1

What I have done

  1. I have created a view.
  2. I have added a content type to display .
  3. I have added a filter to filter by node date content and have opted to display the post date as year in the filter.

What I want actually

I wanted to display only the years that have content. I am using Drupal 7.

Which are the ways to do this?

2 Answers 2

1

If you go to views page (/admin/structure/views), you will find a view "Archive", you can clone it and use it, it will be displaying content month+year using contextual filter "Content: Created year + month", as you want to display only year, use contextual filter ""Content: Created year" and remove "Content: Created year + month".

Screenshot for contextual filter.

enter image description here

Screenshot of output.

enter image description here

It will list all the years that have content added.

Update

What you can do is to create a block of the view, and place it on the page you want, and then when you will click on an year, you can have the content list accordingly on the same page.

enter image description here

4
  • I need the list to be displayed the same page i see the results. That is , when clicking the menu item it goes to results/2015 and the results for 2015 should be displayed along with the list of years(or drop down)
    – Mirza V U
    Commented Nov 3, 2015 at 9:48
  • Do you need this list in page content or in some sidebar, or other portion of page??
    – Dev
    Commented Nov 3, 2015 at 11:49
  • It is a view page content
    – Mirza V U
    Commented Nov 3, 2015 at 11:59
  • Please check, I have updated my answer
    – Dev
    Commented Nov 3, 2015 at 12:06
0
  • Add your fields to view

Add your fields to view

  • Add filter Date: Date(node)

add filter as shown in pic

  • Configure as shown in screenshot

enter image description here

  • I've made it exposed filter, see what you want and do the configuration

enter image description here

  • This is how i get the result

enter image description here

1
  • 1
    It show the years from 2012 to 2018. I wanted only the years to be displayed that have content added.
    – Mirza V U
    Commented Nov 3, 2015 at 6:00

Your Answer

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

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