Convert folder titles with spaces to the safe '-' form

I can get folder names using $project->title()

That returns ‘project A’, for example

I need to use the name as an ‘id’ so I can link to it within a page href.

So I need to convert ‘project A’ to ‘project-a’ in my div and hrefs.

Is there a way to to this, please?

Instead of $project->title(), use $project->uid().

The title() method returns the value of the title field in your content. If that is not set, it uses the folder name.

You should use the uid() method in the first place as @texnixe wrote to make sure that you always get the right value.

I will try not to make my friend edit fields in her site, so I hope to just use folder name where possible. The uid() function seems to give me what I need. Thank-you, both1

Well, if the folder name is changed by the user, the reference to the page id will still be correct. BTW, if you want to make fields not editable, you can always make them readonly via your blueprint field settings.

Thanks, again.

btw. I love using Kirby!