Single Pages

Permalink
I am looking at a way to create a single page with a dash in the name. We currently already have a page that has a dash in the name. We are now converting that page into a single page but it looks like I cannot have a single page with a dash in the name. How am I suppose to be able to do this. By default pages with spaces in the name get dashes but single pages require underscores. Can some please help?

Thanks

 
hutman replied on at Permalink Reply
hutman
Unfortunately you can't create a controller for a Single Page with a hyphen, you can create the page, but the controller will never be recognized.

If you are having the same experience please thumbs up this bug in the Bug Tracker -https://www.concrete5.org/developers/bugs/5-7-5-8/unable-to-create-c...
Parasek replied on at Permalink Reply
Parasek
You can try something like that (although, keep in mind, it was not thoroughly tested by me and add it is kind of a workaround). You will still have single page with underscore-url, but you can always redirect it in .htaccess.

It is propably not the best solution (which would be working dashes for single_pages), but you can try it and decide, if it is enough for you,

1. Create file
application/controllers/page_with_dashes.php

and put there this code:
<?php
namespace Application\Controller;
use Concrete\Core\Page\Controller\PageController;
class PageWithDashes extends PageController
{
    public function pageForTesting()
    {
        $this->replace('/page_for_testing');
    }
}

2. Create
application/single_pages/page_for_testing.php

3. Add single page "page_for_testing" in concrete5 dashboard

4. application/bootstrap/app.php
paste this:
Route::register('page-for-testing', 'Application\Controller\PageWithDashes::pageForTesting');

5. in your .htaccess you can try redirect underscore-url to dash-url
redirect 301 /page_for_testing /page-for-testing

or try to redirect it in php files, maybe?