Help with fundamental concepts - Custom "post/record" storing, Lookups, Admin table for custom records/posts/stream items

I am trying to understand how one could do the following in Grav:

  1. A form outside of any page context that will simply save its data into a custom YAML file (this would be both for the admin or user side). Are there helper tools or do I just dump array to YAML and write? I would like to clarify the steps the framework recommends/allows vs just solving the problem in basic PHP and any info on this note.

  2. How do I write to that form programatically - that is, without visiting the form’s route with a browser, but instead e.g. adding a “Message submission” into “messages.yaml” of a user’s site folder.

  3. How does one do a “lookup” - e.g.

    1. I am looking for one particular array (= “record”) in any YAML file. Some equivalent of (note my human language pseudo syntax): openStream(someStream)->getItemWhere(“Myfield = 15”)
    1. The same but when looking through folders, e.g. which site out of all my sites (on a multisite) has “somefield = 15” inside its relative stream "./data/somestream.yaml

  1. I need custom posts but Pages is too much and too complex for them. The feature to add folders, modular pages, etc is just too complex for the use case. How do people handle that? E.g. a list of blog articles, videos, etc. managed OUTSIDE of the page tree.

  2. And in that line, if the above is already possible, is there an admin plugin that allows viewing arbitrary records/posts and not pages? E.g. here are all items in your stream “/site/messages.yaml” with a simple view/edit form, and the same type of table as is used for Pages, except, of course, it’s not loading pages and defult.md etc. it’s loading items from the messages stream. Basically an admin view for custom forms/blueprints/“posts”.

If there is none, how would one go about doing this?

Thanks!

I can only answer generically, and I don’t use the admin module, so maybe someone else will have more to say about that.

  1. I don’t know what you mean by “outside of any page context.” On the admin side, you should have access to the file system and can create any data files you want. On the user side, they don’t have access to the back end. So where would this form live if not on a page somewhere?

  2. What do you mean by “without visiting the form’s route with a browser”? The only way to communicate with the back end is to actually submit the data to a route. There’s nothing you can do on the client side (JavaScript) that will save anything on the back end without actually visiting some route somewhere. See the Webmention plugin for an example of setting up a custom route and handler. There are other similar plugins as well.

  3. There are many plugins that load data from YAML files and do things with it. There’s also a plugin called Sequential Forms that should be instructive as well.

I’m afraid I can’t help you with 4 and 5. I’m not clear on what you’re trying to accomplish. And I don’t know what you mean by “outside of the page tree.”

Thanks, let me clarify:

  1. I don’t want it to be a page under /pages and don’t want it to appear in the list of Pages admin tab (which will happen if I add a custom page in order to support a route). But of course, it will require a custom route to bevisited.

  2. I mean saving data dynamically in a function, not using a browser to submit data to a route. That is, I want to use PHP inside a plugin to save data to a specific YAML file.

4 & 5 – I just mean that the functionality built around pages is too much. I would want the same type of interface but not for “Page types” but instead just custom arbitrary records/posts that have any fields that I define. To reiterate - records/posts that are devoid of page functionality that comes from system’s default. yml. I want to start from scratch, have only a title, a date, a piece of text (that is, whatever I define) – the basic concept of a “Custom Post” which, in most frameworks, only has an ID and perhaps a date of creation and last editing to start with at the system level. In fact, in some frameworks, the Page data object extends a basic post – and pages provide routing, and publishing options and a slug etc. but all that is opinionated and sometimes I just want a list of things that I define completely on my own.

I want those posts to be edited OUTSIDE of the pages view in the admin, in their own context e.g. “Articles” or “Videos”.

Since you don’t use the admin plugin this probably doesn’t do much for you, but hopefully clarifies for others that are to comment.