i created an ajax page to filter my projects. This page is in the root folder of the content and is available over http://my-domain/ajax-projects?filter=sold for example.
Can i hide this single ajax page from the kirby panel? I dont want to confuse the user, because this page is only to provide ajax calls.
first of all, i don´t realy want to modify the core of kirby. This would cause conflicts when the next update comes up.
I like the way with the custom routes much more. But in the ajax.php i have to load the kirby system that i can use all the helper functions like snippet() and so on. Is there a recommended way to do that?
Custom routes could be defined in your config file, though.
<?php
c::set('routes', array(
array(
'pattern' => 'ajax-projects/(:any)',
'action' => function($filter) {
// Use your filter as appropriate to produce a $data array
return response::json($data);
}
)
));
Donât know if this is the right place for this post or not, but Iâd also like to see a simple way to hide a content page from the panel.
I have a âshow all deadlinesâ page that has no editable content of its own, but draws upon the deadlines that are associated with other site content. I would rather not have this page show up in the panel so the client doesnât get confused on where he has to add new deadlines, and am not sure how to get started with custom routes.
I was thinking something like the current feature where you can hide subpages in the blueprint with âhide: true,â but have this option for the page itself at the top level of itâs associated blueprint file.
If your page has no modifiable content, then it probably shouldnât be in the content folder at all. Unfortunately, one of Kirbyâs limitations is that there is a tight coupling between the content file and the template used if you donât probe beyond basic usage.
However, the router is really very flexible. Like, seriously flexible. Itâs crazy how flexible it is. Itâs worth using the router instead of content files for this sort of basic stuff. You could even wrap this in a plugin instead of setting it via c::set('routes' ...) if you wanted to keep your config lean. The source code is your best documentation at this point and is well worth reading. Kirby is small enough to understand pretty readily.
That may or may not have been my advice. Iâve given it before but not sure if it was to you.
@bastianallgeier, @distantnative it seems the sought after solution of having a high level âhideâ in blueprint that hides the page even from the panel listings. I posted a sample achieving this goal above, but Iâm not sure it was the code was very Bastian like as is, since itâs not well integrated into the system but rather feels like a band aid. It seems like Iâm not the only one waiting to see this as a core feature though and it doesnât seem like itâd take long to add. Perhaps it could be added to the todo list at least.