Home › Forums › Calendar Products › Events Calendar PRO › Different date ranges for different views
- This topic has 9 replies, 2 voices, and was last updated 10 years, 9 months ago by
Brian.
-
AuthorPosts
-
July 28, 2015 at 7:58 am #991039
Irene
ParticipantHi,
on my site I have a calendar view by week and a list view. I have set the calendar to a specific month with a function.
Of course all the views are affected by that function. Would it be possible to have different date ranges for different views?
function tribe_set_default_date () { if ( !is_single() && empty( $_REQUEST['tribe-bar-date'] ) ) { $_REQUEST['tribe-bar-date'] = '2015-01-01'; } } add_action( 'parse_query', 'tribe_set_default_date' );Thanks.
July 28, 2015 at 9:02 am #991094Brian
MemberHi,
Thanks for using our plugins. I can help out here.
I am not 100% sure of what you are trying to do, but we do have this list of conditionals that can help you target specific views:
https://gist.github.com/jo-snips/2415009
Does that help?
July 28, 2015 at 10:43 am #991123Irene
ParticipantHi Brian,
I an building a website for a congress. Under the section “Agenda” I want to show only the week of the congress. In the list widget on top of the site I have some important dates prior the congress that I need to show.
If you go to http://www.spn8.nl you will see what I mean.
I tried:function tribe_set_default_date () { if ( !is_single() && empty( $_REQUEST['tribe-bar-date'] ) ) { $_REQUEST['tribe-bar-date'] = '2016-08-29'; } } if( tribe_is_week()) { // Week View Page add_action( 'parse_query', 'tribe_set_default_date' ); }But the week view still shows the current week.
Thank you
July 28, 2015 at 1:50 pm #991188Brian
MemberHi,
Try adding the conditional in the function and not around the action like this:
function tribe_set_default_date () {
if( tribe_is_week()) { // Week View Page
if ( !is_single() && empty( $_REQUEST['tribe-bar-date'] ) ) {
$_REQUEST['tribe-bar-date'] = '2016-08-29';
}
}
}add_action( 'parse_query', 'tribe_set_default_date' );
July 28, 2015 at 11:26 pm #991269Irene
ParticipantHi Brian,
This doesn’t work either. Giving a good think the problem is probably that the ‘tribe-bar-date’ gives the date for the whole agenda. So I should set a second default-date parameter and target the week view with that. But I have no idea how to do that. I’m not very acquainted with php.
July 29, 2015 at 7:49 am #991413Brian
MemberHi,
Are you just trying to modify the Event List Widget? I am not sure if you mean that or the actual week view found at /events/
I can try to help out here some more, but I am limited in supporting customizations so I cannot provide all the coding you might need.
But let me know about my question and we can go from here.
Thanks
July 29, 2015 at 8:00 am #991426Irene
ParticipantHi Brian,
I try to set the week view found at /events/ beginning by a particular date. I tried with the code you mentioned above but the week begins today, so nothing changes.
I have also tried with this:
function tribe_set_default_date () { if ( !is_single() && empty( $_REQUEST['tribe-bar-date'] ) ) { $_REQUEST['tribe-bar-date'] = '2015-01-01'; } } add_action( 'parse_query', 'tribe_set_default_date' );But then I can’t see the events in the list widget that are prior that date, which is logical.
Thanks
July 29, 2015 at 3:32 pm #991611Brian
MemberHi,
Ok I played around with this and think I got it to work and should not break the list view.
Try out this:
add_action( 'pre_get_posts', 'tribe_set_default_date', 15 );
function tribe_set_default_date ( $query ) {
if ( tribe_is_week() ) {
$query->set( 'eventDate', '2016-08-29' );
}
}That coding will prevent going between weeks of the week view and only enable you to see the week starting on the date set there.
Let me know if that works out for you.
Thanks
July 30, 2015 at 5:22 am #991705Irene
ParticipantFinally! It does work.
Thank you so much. Is exactly what I need.
Cheers
IreneJuly 30, 2015 at 7:41 am #991772Brian
MemberGreat glad it helps.
I am going to close this ticket, but if you need anything else related to this topic or another please post a new topic on the forum and we can help you out.
Thanks
-
AuthorPosts
- The topic ‘Different date ranges for different views’ is closed to new replies.
