Project

General

Profile

Actions

Feature #65998

closed

TypeNum redirect on shortcut page

Added by Arek van Schaijk over 9 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2015-03-24
Due date:
% Done:

0%

Estimated time:
PHP Version:
5.5
Tags:
Complexity:
Sprint Focus:

Description

Hi,

My pagetree looks like:

Website name [1] [shortcut:2]
- Home [2]
- ...

When registrering a new page type by TypoScript:

xml_sitemap = PAGE
xml_sitemap {
    typeNum = 123
    10 = USER_INT
    10 {
        userFunc = TYPO3\MyExtension\Controller\SitemapController
    }
    config {
        disableAllHeaderCode = 1
        additionalHeaders = Content-type:text/xml
        xhtml_cleaning = 0
        // additional configuration
    }
}

http://domain.com/?type=123 is redirected to http://domain.com/?id=2&type=123.

I've configured my typeNum as a filename in the realurl configuration.
So 'sitemap.xml' will be ?type=123

Because 'Website name [1]' is an shortcut to 'Home [2]' domain.com/sitemap.xml is redirected to domain.com/home/sitemap.xml which is obvious pretty ugly :(

After spending some time in the core I figured out that the 'redirect' happens in typo3/sysext/cms/tslib/index_ts.php on line 190.
[[https://forge.typo3.org/projects/typo3cms-core/repository/entry/typo3/sysext/cms/tslib/index_ts.php?rev=TYPO3_6-2#L190]]

When I remove this function here I get my sitemap.xml working under domain.com/sitemap.xml.

I suggest a new page.config like:

xml_sitemap = PAGE
xml_sitemap {
    typeNum = 123
    10 = USER_INT
    10 {
        userFunc = TYPO3\MyExtension\Controller\SitemapController
    }
    config {
        // ...
        *ignorePageRedirect = 1*
    }
}

The TypoScriptFrontendController has already access to this configuration. So checkPageForShortcutRedirect() should be extended with a check like:

Ref: [[https://forge.typo3.org/projects/typo3cms-core/repository/entry/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php?rev=TYPO3_6-2#L3195]]

    public function checkPageForShortcutRedirect() {
        if(!$this->$this->pageRenderer->getIgnorePageRedirect()) {
            if (!empty($this->originalShortcutPage) && $this->originalShortcutPage['doktype'] == PageRepository::DOKTYPE_SHORTCUT) {
                $this->redirectToCurrentPage();
            }
        }
    }

This is backward compatible and does not affect anything.

Actions

Also available in: Atom PDF