1

I would like to organize products in my site by year of production. And sort them in a view. With the date(year) as exposed filter, in this format:

Products :
From  year :…
to year:….

Can I do this only by creating a CCK text field with a list of years? Or should I use the date module instead?

If I have to use this module , How can I change the format in which the date is input. By default, it shows years ,months and days. I want it to show only years.

1

With D6 and views 2.16 (the integer text way approach) is as follows:

Your content type need to have Integer CCK field (year_int).

In your Views create node view, place some field (i.e. title) and add Filter>Content>year_int exposed grater or equal. After add another time Filter>Content>year_int exposed less or equal. Configure the rest as You need and its done.

Notice: you must type years into the filter, there is no select widget available, when field type is text.

Warning! If your type where year is stored is just text (not decimal), filter in views doesn't have less or greater option.

1

Using date field gives you more flexibility, but year made with text field would work also.

But in my opinion after your site grow larger you will probably say to yourself: "Gosh, now I wish to order with moths and days..." and you'll regret not using date field at the beginning.

  • Thank you, any idea how to change the format in date module input , to show only years? Can I do this, just by using (Y) as Custom input format? – Nizarnav Mar 19 '12 at 13:14
  • What views version? – Gregory Zbinsky Mar 19 '12 at 13:35
  • Views version: 6.x-2.16 – Nizarnav Mar 19 '12 at 13:43
  • Yes, EXACTLY what I'm looking for. – Nizarnav Mar 19 '12 at 15:15
0

With D6 and views 2.16 and date 2.8 (the suggested date way approach) is as follows:

You have to have date field in your content with granularity year (field_date). You can choose list to provide year list when updating/creating product with some range.

In your Views create node view, place some field (i.e. title) and add Filter>Content>field_date exposed grater or equal. After add another time Filter>Content>field_date exposed less or equal. Configure the rest as You need and its done.

Date approach is more flexible and scalable in my opinion and gives more widgets when adding, editing and exposing in views filter. It's just smarter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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