Project

General

Profile

Actions

Task #86585

closed

Configurability of page routing

Added by Daniel Dorndorf about 6 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Site Handling, Site Sets & Routing
Target version:
-
Start date:
2018-10-06
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Sprint Focus:

Description

If I wanted to use .html as url prefix I had to extend the default page decorator

On rootpages it would generate /index.html else.

PageTypeSuffix:
  type: CustomPageType
  default: '.html'
  index: 'index'
  map:
    '.html': 0
class CustomPageTypeDecorator extends PageTypeDecorator
{
    public const IGNORE_INDEX = [
        '/index.html',
        '/index/',
    ];

    public const ROUTE_PATH_DELIMITERS = ['.', '-', '_', '/'];

    /**
     * @param \TYPO3\CMS\Core\Routing\RouteCollection $collection
     * @param array $parameters
     */
    public function decorateForGeneration(RouteCollection $collection, array $parameters): void
    {
        parent::decorateForGeneration($collection, $parameters);

        /**
         * @var string $routeName
         * @var \TYPO3\CMS\Core\Routing\Route $route
         */
        foreach ($collection->all() as $routeName => $route) {
            $path = $route->getPath();

            if (true === \in_array($path, self::IGNORE_INDEX, true)) {
                $route->setPath('/');
            }
        }
    }
}

Related issues 1 (1 open0 closed)

Related to TYPO3 Core - Task #86887: Enable urls like `https://example.com/` and `https://example.com/path/to/site.html`, so only `.html` suffix for page type 0 if there is a path.New2018-11-08

Actions
Actions

Also available in: Atom PDF