Changing names for pages from a form

I used

to create pages from a form, which worked fine.

However, I would like to change the following on the generated pages:

The created page folders have names like “3ae90af0d8860d97f3f9f0b578ef7198”. How can I insert the “name” from the form instead?

How can I additionally send an email to a certain address with the message that a new page has been added?

This is the line that determines the folder name:

'slug'     => md5(str::slug($data['name'] . microtime())),

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'):

  'from' => '',
  'to' => '',
  '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?

Probably, if sending mail is not enabled.

Thank you for the support.

You are welcome!

You can try using an external service or enable it locally.

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?

?? You mean it is displayed in the page? Can you post a link?

Removed Link

That looks like your error page? If the newly created page is a draft and you are not logged in, you get the error page.

Strange this is that if I fill the form, I don’t get any feedback if the form was sent successfully?

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.

What could be the reason for this behaviour?

Maybe I was on the wrong page, I meant this form:

Yes, thats the wrong page.

Removed Link

is the correct not working page.

And that page is published?

It is now.

That seems to have been the problem. But why is the page displayed as soon as you log in to the panel?

Many thanks again.

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.