Schedule Blog-Posts plugin

Hi,
after playing around with this great hint for filtering by date there came an idea to my mind of a plugin that ads this filter default to all visible pages - globaly.
Maybe it is possible to auto-add
->filterBy('date', '<=', time())
to
->visible()
internaly/globaly/etc. instead of editing every template/plugin/etc. (e.g. search and feed-plugin, etc…) seperated?

thx in advance

I think the best way would be to create a custom pages method and then use something like this …

$pages->filterScheduled()

I‘m not sure, but I think it‘s even possible to override ->visible() this way, if you don‘t want to change all the templates.

You cannot override a method in a custom method. If you want to override an existing method, you have to use a page model, which then doesn’t work globally but only for the pages that use the corresponding template. I’m not so sure that adding this functionality to the visibility flag globally makes much sense, though. Filtering by date only makes sense for something like posts that do have a date field. This usually doesn’t apply to all pages in a site.

There is also already a scheduled pages plugin: https://github.com/jenstornell/kirby-scheduled-pages

It doesn’t override existing methods, though.

1 Like

Using it globaly still makes sense, also when pages do not have date field. because scheduling is allways something that depends on dates, pages without dates seem not to rely on any date-specific feature. so it is not a problem, when those pages without dates are used beside a globaly schedule by date.

i totaly agree, that such a functionality should not be default. but in a plugin it would help on demand, regardless of other plugins and pre-coded templates.

I’m not sure if it helps you with all the problems but I made a plugin where it’s possible to, for example redirect globally depending on a field. See example 2:

As I said above, it is not possible to overwrite an existing method globally. Also, in my opinion it makes more sense to use a specific custom method for this purpose, as already mentioned by @flokosiol. Please also note that visibility is just a filter flag, it doesn’t make a page inaccessible. Additionally, you have to make sure that visitors can’t access those pages .

1 Like