Classes/Page/RobotsTxtPage.php
public function main()
    {
        $ret = '';

        $settings = GeneralUtility::getRootSetting();

        // INIT
        $this->tsSetup = $GLOBALS['TSFE']->tmpl->setup;
        $this->cObj    = $GLOBALS['TSFE']->cObj;
        $this->rootPid = GeneralUtility::getRootPid();

        $this->tsSetupSeo = null;
        if (!empty($this->tsSetup['plugin.']['metaseo.']['robotsTxt.'])) {
            $this->tsSetupSeo = $this->tsSetup['plugin.']['metaseo.']['robotsTxt.'];
        }

        // check if sitemap is enabled in root
        if (!GeneralUtility::getRootSettingValue('is_robotstxt', true)) {
            return true;
        }

        $this->linkToStaticSitemap = GeneralUtility::getRootSettingValue('is_robotstxt_sitemap_static', false);

        // Language lock
        $this->sitemapLanguageLock = GeneralUtility::getRootSettingValue('is_sitemap_language_lock', false);
        $this->languageId          = GeneralUtility::getLanguageId();

        // ###############################
        // Fetch robots.txt content
        // ###############################
        $settings['robotstxt'] = trim($settings['robotstxt']);

        if (!empty($settings['robotstxt'])) {
            // Custom Robots.txt
            $ret .= $settings['robotstxt'];
        } elseif ($this->tsSetupSeo) {
            // Default robots.txt
            $ret .= $this->cObj->cObjGetSingle($this->tsSetupSeo['default'], $this->tsSetupSeo['default.']);
        }

        // ###############################
        // Fetch extra robots.txt content
        // ###############################
        // User additional
        if (!empty($settings['robotstxt_additional'])) {
            $ret .= "\n\n" . $settings['robotstxt_additional'];
        }

        // Setup additional
        if ($this->tsSetupSeo) {
            // Default robots.txt
            $tmp = $this->cObj->cObjGetSingle($this->tsSetupSeo['extra'], $this->tsSetupSeo['extra.']);

            if (!empty($tmp)) {
                $ret .= "\n\n" . $tmp;
            }
        }

        // ###############################
        // Marker
        // ###############################
        if (!empty($this->tsSetupSeo['marker.'])) {
            $ret = $this->applyMarker($ret);
        }

        // Call hook
        GeneralUtility::callHookAndSignal(__CLASS__, 'robotsTxtOutput', $this, $ret);

        return $ret;
    }
public function main()
    {
        $ret = '';

        $settings = GeneralUtility::getRootSetting();

        // INIT
        $this->tsSetup = $GLOBALS['TSFE']->tmpl->setup;
        $this->cObj    = $GLOBALS['TSFE']->cObj;
        $this->rootPid = GeneralUtility::getRootPid();

        $this->tsSetupSeo = null;
        if (!empty($this->tsSetup['plugin.']['metaseo.']['robotsTxt.'])) {
            $this->tsSetupSeo = $this->tsSetup['plugin.']['metaseo.']['robotsTxt.'];
        }

        // check if sitemap is enabled in root
        if (!GeneralUtility::getRootSettingValue('is_robotstxt', true)) {
            return true;
        }

        $this->linkToStaticSitemap = GeneralUtility::getRootSettingValue('is_robotstxt_sitemap_static', false);

        // Language lock
        $this->sitemapLanguageLock = GeneralUtility::getRootSettingValue('is_sitemap_language_lock', false);
        $this->languageId          = GeneralUtility::getLanguageId();

        // ###############################
        // Fetch robots.txt content
        // ###############################
        $settings['robotstxt'] = trim($settings['robotstxt']);

        if (!empty($settings['robotstxt'])) {
            // Custom Robots.txt
            $ret .= $settings['robotstxt'];
        } elseif ($this->tsSetupSeo) {
            // Default robots.txt
            $ret .= $this->cObj->cObjGetSingle($this->tsSetupSeo['default'], $this->tsSetupSeo['default.']);
        }

        // ###############################
        // Fetch extra robots.txt content
        // ###############################
        // User additional
        if (!empty($settings['robotstxt_additional'])) {
            $ret .= "\n\n" . $settings['robotstxt_additional'];
        }

        // Setup additional
        if ($this->tsSetupSeo) {
            // Default robots.txt
            $tmp = $this->cObj->cObjGetSingle($this->tsSetupSeo['extra'], $this->tsSetupSeo['extra.']);

            if (!empty($tmp)) {
                $ret .= "\n\n" . $tmp;
            }
        }

        // ###############################
        // Marker
        // ###############################
        if (!empty($this->tsSetupSeo['marker.'])) {
            $ret = $this->applyMarker($ret);
        }

        // Call hook
        GeneralUtility::callHookAndSignal(__CLASS__, 'robotsTxtOutput', $this, $ret);

        return $ret;
    }
public function main ( ) { $ ret = '' ; $ settings = GeneralUtility :: getRootSetting ( ) ; // INIT $ this -> tsSetup = $ GLOBALS [ 'TSFE' ] -> tmpl -> setup ; $ this -> cObj = $ GLOBALS [ 'TSFE' ] -> cObj ; $ this -> rootPid = GeneralUtility :: getRootPid ( ) ; $ this -> tsSetupSeo = null ; if ( ! empty ( $ this -> tsSetup [ 'plugin.' ] [ 'metaseo.' ] [ 'robotsTxt.' ] ) ) { $ this -> tsSetupSeo = $ this -> tsSetup [ 'plugin.' ] [ 'metaseo.' ] [ 'robotsTxt.' ] ; } // check if sitemap is enabled in root if ( ! GeneralUtility :: getRootSettingValue ( 'is_robotstxt' , true ) ) { return true ; } $ this -> linkToStaticSitemap = GeneralUtility :: getRootSettingValue ( 'is_robotstxt_sitemap_static' , false ) ; // Language lock $ this -> sitemapLanguageLock = GeneralUtility :: getRootSettingValue ( 'is_sitemap_language_lock' , false ) ; $ this -> languageId = GeneralUtility :: getLanguageId ( ) ; // ############################### // Fetch robots.txt content // ############################### $ settings [ 'robotstxt' ] = trim ( $ settings [ 'robotstxt' ] ) ; if ( ! empty ( $ settings [ 'robotstxt' ] ) ) { // Custom Robots.txt $ ret .= $ settings [ 'robotstxt' ] ; } elseif ( $ this -> tsSetupSeo ) { // Default robots.txt $ ret .= $ this -> cObj -> cObjGetSingle ( $ this -> tsSetupSeo [ 'default' ] , $ this -> tsSetupSeo [ 'default.' ] ) ; } // ############################### // Fetch extra robots.txt content // ############################### // User additional if ( ! empty ( $ settings [ 'robotstxt_additional' ] ) ) { $ ret .= "\n\n" . $ settings [ 'robotstxt_additional' ] ; } // Setup additional if ( $ this -> tsSetupSeo ) { // Default robots.txt $ tmp = $ this -> cObj -> cObjGetSingle ( $ this -> tsSetupSeo [ 'extra' ] , $ this -> tsSetupSeo [ 'extra.' ] ) ; if ( ! empty ( $ tmp ) ) { $ ret .= "\n\n" . $ tmp ; } } // ############################### // Marker // ############################### if ( ! empty ( $ this -> tsSetupSeo [ 'marker.' ] ) ) { $ ret = $ this -> applyMarker ( $ ret ) ; } // Call hook GeneralUtility :: callHookAndSignal ( __CLASS__ , 'robotsTxtOutput' , $ this , $ ret ) ; return $ ret ; }
Fetch and build robots.txt
Fetch and build robots . txt