Re "Creating pages from frontend" cookbook example

Complete noob with Kirby. I’ve managed to set up some custom page module snippets and set up my demo/test site so far. Creating content is great with Kirby, but i’m honestly not that much of a developer and I find the above mentioned tutorial from the cookbook utterly confusing / am overwhelmed.

So far I’ve created the registration-form.php and saved it in my “snippets” directory and created the “event.php” and saved it as a controller. Then the tutorial talks from another “event.php” that I’m supposed to save as a template. Done all that. No where can I add the registration form to a page, also when creating a new page I can’t find the event template in the template selection.

How do I include the form in a page or where is the registration form?

You need the following files:

  • the event.php controller in /site/controllers
  • the event.php template in /site/templates
  • the registration-form.php snippet in site/snippets

I just noticed there is an error in the template, this line

snippet('form', compact('data'));

should actually be

snippet('registration-form', compact('data'));

(because that’s what the snippet is called), that is why the form doesn’t show up.

For the Panel, you would have to create a parent page (events) and subpages with an event.yml blueprint in site/blueprints. That is not part of the recipe, because the recipe deals with advanced stuff. Since you are new to Kirby, I recommend you read the basic documentation first, so that you know how to create blueprints for the Panel and what templates and controllers are good for.

1 Like

Ah I see, you are absolutely right. I omitted making a blueprint / yaml file, as it was not part of the tutorial. I did actually read up a bit on blueprints and have managed to create a simple blueprint for making recurrent / similar posts based on items from a select form, but I misunderstood the whole “creating content from the frontend” thing. I will definitely need to read up on how controllers work, that is completely unknown terrain so far.

Thank you very much for lending me a hand!

You are welcome.

So what you need is an events parent (with an events.yml blueprint), then in that events.yml blueprint, limit children to the event template and create an event.yml blueprint for these children pages.

Hello again. Even though I’ve reread all the advice you’ve given me (thank you for that) and double checked, all i get is an ominous generic error that does not help at all (" Illegal offset type in isset or empty" ) when calling the events page which should feature the form as a snippet. In the panel / backend I can enter data into the fields, but it always overwrites the previous entries (not a big deal as I wouldn’t be using that anyway). The only way to see the form is if I call the “event/registrations” url and even then it does nothing when submitted, not even an error message.

So I’m still completely at a loss. All I would like to do is implement is a simple form with 5 or 6 fields and save the data from visitors in a text file, currently this seem unnecessary difficult and/or way over my head. It seems the CMS does not support the use of forms “out of the box” and the learning curve is far too steep for me.

Here is a working example:

Note that each event page has a registration subpage that is auto-created when a new event is created, I forgot to mention that above and have to add this to the recipe. All pages from the registration forms in stored there.

Don’t know if this will help you or not. For form handling, there is also a very good Kirby plugin (Kirby Uniform).

That is right. Kirby is in fact not comparable to Wordpress, where you either get a lot of stuff built-in that you will never use or you install a lot of plugins. In fast, Kirby does require some basic PHP knowledge or a willingness to learn the API and those basics. If you need something that works out of the box and has everything in place, then Kirby might in fact not be for you.

All I can do is support you as best I can, the rest you have to decide for yourself.

1 Like

Hey texnixe,

you’ve been extremely helpful. Sorry about my frustration, it is just that Kirby was recommended from a friend and obviously he over-estimated my capability to modify the CMS appropriately. Even though it is for a rather small site, I do need some basic features. I will look into the Uniform mod and read up to better understand the example.

Again thank you for your help and explanation so far.

1 Like