change it to your liking. The encoded slug is used to make sure that folder names are unique, which they will not necessarily be if you use the name only.
To send an email on successful page creation, send the email before the go('success') redirect.
Yes, that’s right, the unique names for the folders actually make sense. I added a title field to the form, which fixed the problem.
Sending emails from the event controller doesn’t work though. I added the following code before go('success'):
$kirby->email([
'from' => 'someone@thiscorp.com',
'to' => 'somebody@thatfirm.com',
'subject' => 'A new ad has been added!',
'body'=> 'A new ad has been added!',
]);
Why doesn’t this work?
Is it because the site currently runs local with mamp?
I have now uploaded the website to a server to test the email delivery, but I get an “Error”. In MAMP it works, as I said, but there I can’t test the sending of emails. Strangely enough, the error is not displayed in the debugger, but at the point where the first word from the page’s txt file should appear, the txt file content does not load at all. The “error” is only on the page containing the form, everything else works.
Since the website is located in a subdirectory on the server, I tried adding “RewriteBase /foldername” to the htaccess, but the error remains.
Why could it be that the ‘Creating pages from frontend’-form works with MAMP, but not on the server?
I just logged in to the panel and added some text to the error page to test if it is shown (even though the page address wasn’t ‘error’ in the address bar) and now everything suddenly works, emailing and ‘success’ feedback. I probably only had to log in to the panel once, didn’t I?
If you saw the form, it must have been after I logged in, because it wasn’t displayed before.
No, it’s not working yet. If I call the form page with Firefox (or any other browser for the first time) instead of Chrome, I get the same error again. When I log in to the site panel in firefox, the form page is displayed afterwards.
Considering this, it’s really strange that the form was displayed in your browser.
That’s what I said above, a draft is only visible to logged in users, so if you try to access it as a normal user, you are redirected to the error page.