Different date ranges for different views

Home Forums Calendar Products Events Calendar PRO Different date ranges for different views

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #991039
    Irene
    Participant

    Hi,

    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.

    #991094
    Brian
    Member

    Hi,

    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?

    #991123
    Irene
    Participant

    Hi 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

    #991188
    Brian
    Member

    Hi,

    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' );

    #991269
    Irene
    Participant

    Hi 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.

    #991413
    Brian
    Member

    Hi,

    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

    #991426
    Irene
    Participant

    Hi 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

    #991611
    Brian
    Member

    Hi,

    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

    #991705
    Irene
    Participant

    Finally! It does work.

    Thank you so much. Is exactly what I need.

    Cheers
    Irene

    #991772
    Brian
    Member

    Great 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

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Different date ranges for different views’ is closed to new replies.