- Issue created by @flitt1
I've created a patch that removes the update status changes that were done to the default office hours formatter. With this change, the hours display is shown to anonymous users as expected (without the update script overwriting the display).
If someone knows a way to keep the cache update stuff in there but also respect the display settings that would be better, I just don't know how to do that.
- 🇳🇱Netherlands johnv
The JS is added to circumvent the problems with field cache for anonymous users → , when you have an open/close status displayed, or not all days per week, with page_cache enabled.
I wonder, why a contrib field should worry about the layout builder peculiarities.
There is now an exception in theming, according to the fix in 🐛 Layout Builder error with 'Exception Day' Fixed . The relevant code is now in office_hours.theme.inc .
I guess it can/should be moved to some 'real' php code . - 🇳🇱Netherlands johnv
Thanks for your report.
The root cause is in core\modules\layout_builder\src\Entity\LayoutBuilderEntityViewDisplay.php::buildMultiple().public function buildMultiple(array $entities) { $build_list = parent::buildMultiple($entities); // Layout Builder can not be enabled for the '_custom' view mode that is // used for on-the-fly rendering of fields in isolation from the entity. if ($this->isCustomMode()) { return $build_list; } // ... }
And this is exactly what happens. The field is rendered again, in isolation.
- Status changed to Fixed
about 1 year ago 8:55am 3 November 2023 - 🇳🇱Netherlands johnv
Thanks for the report. Committed a smarter fix.
Apparently you have a cache-dependent display. (using exceptions, or open/closed/current/next formatter).
Please test the following:
- edit an entity. Make sure the entity opens/closes in a few minutes.
- as an anonymous user, display the entity. Check the open/close indicator
- before the open/close indicator, refresh the page some times (use CTRL-F5 once to refresh JS file, further F5)
- wait until the opening/closing time has passed, and refresh the page (F5), check the open/closed indicatorEach time, the data can be fetched from cache or created new. In your case, the 'read from cache and update field with JS' is now disabled.
Automatically closed - issue fixed for 2 weeks with no activity.