- Posts: 295
COMMUNITY FORUM
Show items with current creation date
- stavroch
-
Topic Author
- Offline
- Elite Member
Please Log in or Create an account to join the conversation.
- stavroch
-
Topic Author
- Offline
- Elite Member
- Posts: 295
Please Log in or Create an account to join the conversation.
- stavroch
-
Topic Author
- Offline
- Elite Member
- Posts: 295
My site is an entertainment portal. For example I have category with the cinema movies. I have define on the creation date the date where the movie will start. So I would like to display on the category page the whole items where start today. (creation date = current date).
Please Log in or Create an account to join the conversation.
- stavroch
-
Topic Author
- Offline
- Elite Member
- Posts: 295
Please Log in or Create an account to join the conversation.
- stavroch
-
Topic Author
- Offline
- Elite Member
- Posts: 295
Please Log in or Create an account to join the conversation.
- stavroch
-
Topic Author
- Offline
- Elite Member
- Posts: 295
Please Log in or Create an account to join the conversation.
- stavroch
-
Topic Author
- Offline
- Elite Member
- Posts: 295
Please Log in or Create an account to join the conversation.
- Jiliko.net
-
- Offline
- Platinum Member
- Posts: 567
What you can do is creating a K2 template override and add some code in the 'category.php' file to filter items by current date before they're being displayed.
Olivier
Please Log in or Create an account to join the conversation.
- stavroch
-
Topic Author
- Offline
- Elite Member
- Posts: 295
Please Log in or Create an account to join the conversation.
- troponin
-
- Offline
- Platinum Member
- Posts: 398
but I think Olivier aka Yoda should correct me - could be that the code isn't 100% correct. Didn't tried it.
Stavros said:What kind of code do I have to write?
Please Log in or Create an account to join the conversation.
- Jiliko.net
-
- Offline
- Platinum Member
- Posts: 567
Olivier
Troponin said: should be something similiar to --> see attachment
but I think Olivier aka Yoda should correct me - could be that the code isn't 100% correct. Didn't tried it.
Stavros said:What kind of code do I have to write?
Please Log in or Create an account to join the conversation.
- stavroch
-
Topic Author
- Offline
- Elite Member
- Posts: 295
I paste the
I get white page. The source code of this file is
How can I change it to work?
Please Log in or Create an account to join the conversation.
- troponin
-
- Offline
- Platinum Member
- Posts: 398
<-- Leading items -->
till
<-- Pagination -->
The other Question is:
What about Date Formating - does it matter for getdate() ?
Maybe someone could answer...
Please Log in or Create an account to join the conversation.
- stavroch
-
Topic Author
- Offline
- Elite Member
- Posts: 295
Please Log in or Create an account to join the conversation.
- stavroch
-
Topic Author
- Offline
- Elite Member
- Posts: 295
Please Log in or Create an account to join the conversation.
- Jiliko.net
-
- Offline
- Platinum Member
- Posts: 567
I've checked the code and the test is not at the right place.
But, more important is that by hiding the items with date != today, you're gonna have layout & pagination problems.
Let me explain :
K2 got a function that retrieves items with params corresponding to the itemlist menu you've configured (ordering, # of items in primary, secondary, etc).
This function returns a number of items and pagination is generated from this result.
In the category.php, You've got all the returned items (let say 20 items), if you filter with date = today, you may now have 6 items, so pagination won't be right anymore and primary, secondary columns won't display the items correctly due to missing items in the item list.
The best thing to do would be to modify K2 core files to add a new param in item filter list like 'Only today item'.
Olivier
Please Log in or Create an account to join the conversation.
- stavroch
-
Topic Author
- Offline
- Elite Member
- Posts: 295
Please Log in or Create an account to join the conversation.
- stavroch
-
Topic Author
- Offline
- Elite Member
- Posts: 295
Please Log in or Create an account to join the conversation.
- Jiliko.net
-
- Offline
- Platinum Member
- Posts: 567
In attachment, a category.php modified file that retrieves the x items of the day and displays them before the core item list.
You can configure in the file the number of items of the day to display. The items are sorted the same way as other files.
Sure, all this could be done in a nice K2 plugin but the essential is here.
Olivier
Please Log in or Create an account to join the conversation.
- stavroch
-
Topic Author
- Offline
- Elite Member
- Posts: 295
Thank for your job some elements are not closed to the right position.
Also it doesn't display the image of items on the category page.
I am waiting your new version
Please Log in or Create an account to join the conversation.