You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The setting useCustomPageTemplate allows the shortcode to be added to a page which doesn't use template calendar.html.twig, which gives me the impression that template calendar.html.twig isn't needed at all.
It seems the main use of calendar.md is to selectively activate the plugin instead of activating it on each and every page.
Considering the above, other ways of activating the plugin selectively could be used.
Two alternatives:
Both alternative provide the user the ability to add the shortcode to any page, without using template calendar.html.twig and still only active the plugin on specific pages.
In fullcalendar.php only add assets when frontmatter contains fullcalendar === true:
public function onPluginsInitialized()
{
...
$this->enable([
'onGetPageTemplates' => ['onGetPageTemplates', 0],
'onShortcodeHandlers' => ['onShortcodeHandlers', 0],
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
'onPageInitialized' => ['onPageInitialized', 0],
]);
}
public function onPageInitialized(Event $event)
{
/** @var Page */
$page = $event['page'];
if (isset($page->header()->fullcalendar) && $page->header()->fullcalendar === true) {
$this->addAssets();
}
Advantage/disadvantage
Option 1
Advantage:
None of the events will be handled when not on route.
Disadvantage:
When items containing shortcode are shown on /blog using filter, the route becomes /blog/tag:photography#body-wrapper. This can be fixed by using regex when comparing. Eg. #/blog(/.*)?#
Option 2
Advantage:
No problems with filtered blog items (see above)
Disadvantage: Some events are run before onPageInitialized and must be handled.
The text was updated successfully, but these errors were encountered:
well, calendar.html.twig is used to selectively activate the plugin instead of activating it on each and every page,
that is correct.
but the template does also additional things, which were the reason to use it even before.
one is to find calendar files (.ics) in the page folder and, if found, adds them to the calendars to display.
another is to provide the monthly picture feature.
so, it is needed for anyone who wants the mentioned features.
plus, anyone who does not like it as-is, can make a copy in the theme folder (which will then override the original) and modify that at will, according to other needs.
the useCustomTemplate Flag, however, is somewhat obscure, and ATM not so well documented, I agree.
I'll think about the proposed options, tend to #2.
however, I will first try to solve issue #44, which is more important, I think.
Option 2 has now been implemented, the useCustomTemplate Flag is kept for backwards compatibility, but removed from the blueprint - also mentioned in the docs.
The setting
useCustomPageTemplate
allows the shortcode to be added to a page which doesn't use templatecalendar.html.twig
, which gives me the impression that templatecalendar.html.twig
isn't needed at all.It seems the main use of
calendar.md
is to selectively activate the plugin instead of activating it on each and every page.Considering the above, other ways of activating the plugin selectively could be used.
Two alternatives:
Both alternative provide the user the ability to add the shortcode to any page, without using template
calendar.html.twig
and still only active the plugin on specific pages.Option 1
route
in config fileIn fullcalendar.php only enable eventhandlers when page is on route:
Option 2
Add new variable to frontmatter of page on which plugin should be activated:
In fullcalendar.php only add assets when frontmatter contains
fullcalendar === true
:Advantage/disadvantage
Option 1
Option 2
onPageInitialized
and must be handled.The text was updated successfully, but these errors were encountered: