Closed keiserjb closed 1 month ago
So, if I get it right, you want to set either the validRange or the initialDate - or probably both?
Hm. Just saw a "reminder to self" in the source code to let modules extend the settings.
But maybe a UI setting makes sense, too. (possibly later)
A PR is available for testing: #29
With that minimal change, you get full control over FC options. You can achieve what you want with code like:
/**
* Implements hook_preprocess_HOOK().
*/
function foobar_preprocess_page($variables) {
// Possibly wrap this code in if statement to only apply on necessary pages.
$options = array(
// @see https://fullcalendar.io/docs/validRange
'validRange' => array(
'start' => '2022-10-30',
'end' => '2022-12-30',
),
// @see https://fullcalendar.io/docs/initialDate
'initialDate' => '2022-11-01',
);
backdrop_add_js(array('fullcalendar_views_custom' => $options), 'setting');
}
Where "foobar" is the name of your module (or even theme).
Alternative, if you need some info from the view - HOOK_views_pre_render:
/**
* Implements HOOK_views_pre_render().
*/
function YOURMODULE_views_pre_render(&$view) {
if ($view->name == 'YOURVIEW') {
$options = array(
'initialDate' => '2022-11-01',
);
backdrop_add_js(array('fullcalendar_views_custom' => $options), 'setting');
}
}
Hm... neither feedback nor any testing - @keiserjb I assume that you fixed your problem differently.
However, I planned to add that $.extend
anyway, so I'll merge.
Did not actually do anything with it. But I might try today.
Added the second pre_render function to my theme and it worked but didn't preview that way inside the view.
I'll go with that for now.
Added the second pre_render function to my theme and it worked but didn't preview that way inside the view.
@keiserjb could you elaborate that a bit? I'm not sure if I understand what "didn't preview that way inside the view" means. In a local demo the views preview also showed my customized values.
I meant that when clicking update preview inside the view it did not reflect the change but then viewing the page did.
when clicking update preview inside the view it did not reflect the change...
Strange, it worked on my testing install. Maybe some caching / aggregation problem?
I'll go with that for now
So, actually you'd still prefer a UI (form items) for that? So, let's reopen this issue and see what other feedback lands here.
I'm having trouble with the site I wanted to use this on. It works everywhere else.
Got it completely working with the correct date on the calendar. But yes, this would be nice to configure within the view setup and not in the theme template.
I think this would be useful to have in the UI for where there are lots of events in a future event.
Slightly different use case but I'm also interested in initialDate
-- rather than manually setting to some future date, I'm wondering how to make Views filters work more smoothly with the calendar.
For example:
The result seems to be that you get the filter applied, but the calendar jumps back to the initial view. It would be nice if the initialDate
could follow the current position of the pager so a filter that was applied after browsing the calendar would still be on the same date/page.
It would be nice if the initialDate could follow the current position of the pager so a filter that was applied after browsing...
I'm not sure if I really get, what you're after, so here some assumptions.
Do you mean, that the filter should be applied to (sort of) the currently active calendar page only? So, rather than a (Backdrop) views filter (that's always for the database result, not the display, and reloads the calendar), you'd want to toggle displays on and off only for the calendar view? Seems a bit complex at first sight, and would be JS based... didn't try, yet.
Currently the value of initialDate isn't set, neither is visibleRange. You could make that a function in a custom extension (JS). But as the calendar is completely reloaded with views filters... where to store the active date (maybe localStorage...).
If my assumptions are right, you'd need something completely different, than the initial report here suggests. Maybe a new issue? But be warned, it seems like something this module can't provide out of the box (too many variables). But maybe we can elaborate something.
I'm closing this issue, as the initially reported problem has been fixed a while ago.
The newly added problem got its own issue in #44 and its own PR as a suggested solution.
I took a look through the issues and haven't noticed this use case. I have a site with date fields that I'd like to use on a calendar. However, the events don't begin for several months and I don't want to show an empty calendar. I want the calendar to begin when the events do.
The D9 version of full calendar has this.
Would love to be able to say start the calendar on the date of the first view result or just have a default date.
I'm attempting to possibly get this to work and send a pr but it is not working as of yet. Putting in the issue to see if you have a solution.