Typo3:スケジューラ/クロンスクリプトでTypolinksを作成する方法

StackOverflow https://stackoverflow.com/questions/7364601

  •  28-10-2019
  •  | 
  •  

質問

スケジューラタスク内のフロントエンドWebサイトへのリンクを作成する必要があります。私は検索して回避しましたが、私が見つけたのは、TSFEを開始する例です。その後、TSLIB_COBJを開始していくつかのリンクを作成できます。私は思った。

しかし、私が得るのは、$ cobj-> typolink_url(1)を使用してTypolinkを作成しようとするとすぐに再帰エラーです。 fe。またはTypolinkを作成できる他の方法。

以下は、フロントエンドの拡張機能内で作業するときと同じように、$ globals内でTSFEを開始するために使用するスクリプトです。

<?php
function initTSFE($pageUid = 1, $overrule = FALSE) {
    // declare
    $temp_TSFEclassName = t3lib_div::makeInstanceClassName('tslib_fe');

    // begin
    if (!is_object($GLOBALS['TT']) || $overrule === TRUE) {
        $GLOBALS['TT'] = new t3lib_timeTrack;
        $GLOBALS['TT']->start();
    }

    if ((!is_object($GLOBALS['TSFE']) || $overrule === TRUE) && is_int($pageUid)) {
        // builds TSFE object
        $GLOBALS['TSFE'] = new $temp_TSFEclassName($GLOBALS['TYPO3_CONF_VARS'],
            $pageUid, $type=0, $no_cache=0, $cHash='', $jumpurl='', $MP='', $RDCT='');

        // builds rootline
        $GLOBALS['TSFE']->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
        $rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($pageUid);

            // init template
        $GLOBALS['TSFE']->tmpl = t3lib_div::makeInstance('t3lib_tsparser_ext');
        $GLOBALS['TSFE']->tmpl->tt_track = 0;// Do not log time-performance information
        $GLOBALS['TSFE']->tmpl->init();

        // this generates the constants/config + hierarchy info for the template.
        $GLOBALS['TSFE']->tmpl->runThroughTemplates($rootLine, $start_template_uid=0);
        $GLOBALS['TSFE']->tmpl->generateConfig();
        $GLOBALS['TSFE']->tmpl->loaded=1;

        // get config array and other init from pagegen
        $GLOBALS['TSFE']->getConfigArray();
        $GLOBALS['TSFE']->linkVars = ''.$GLOBALS['TSFE']->config['config']['linkVars'];

        if ($GLOBALS['TSFE']->config['config']['simulateStaticDocuments_pEnc_onlyP']) {
            foreach (t3lib_div::trimExplode(',',$GLOBALS['TSFE']->config['config']['simulateStaticDocuments_pEnc_onlyP'],1) as $temp_p) {
                $GLOBALS['TSFE']->pEncAllowedParamNames[$temp_p]=1;
            }
        }

        // builds a cObj
        $GLOBALS['TSFE']->newCObj();
    }
}

スケジューラタスクで私がTODOを試しているのは、次のとおりです。

<?php
public function execute() {
    $this->initTSFE();
    $cObj = t3lib_div::makeInstance('tslib_cObj');
    var_dump($cObj->getTypoLink_URL(1));exit;
}

これは、スケジューラを介してこのタスクを実行すると、次の結果を示しています。http://i.imgur.com/dhzys.png

どんな助けもとても高く評価されています=)

注:gettypolink_url内の1つの値は、typo3のページとして存在します。

役に立ちましたか?

解決

私が使用しようとしていたこのinittsfe()方法には何か問題があるようです。私は確かにやめていませんが、機能しているように見える別のバージョンを見つけました:

public function initTSFE($pageUid=1) {
    require_once(PATH_tslib.'class.tslib_fe.php');
    require_once(PATH_t3lib.'class.t3lib_userauth.php');
    require_once(PATH_tslib.'class.tslib_feuserauth.php');
    require_once(PATH_t3lib.'class.t3lib_cs.php');
    require_once(PATH_tslib.'class.tslib_content.php');
    require_once(PATH_t3lib.'class.t3lib_tstemplate.php');
    require_once(PATH_t3lib.'class.t3lib_page.php');

    $TSFEclassName = t3lib_div::makeInstanceClassName('tslib_fe');

    if (!is_object($GLOBALS['TT'])) {
        $GLOBALS['TT'] = new t3lib_timeTrack;
        $GLOBALS['TT']->start();
    }

    // Create the TSFE class.
    $GLOBALS['TSFE'] = new $TSFEclassName($GLOBALS['TYPO3_CONF_VARS'],$pageUid,'0',1,'','','','');
    $GLOBALS['TSFE']->connectToMySQL();
    $GLOBALS['TSFE']->initFEuser();
    $GLOBALS['TSFE']->fetch_the_id();
    $GLOBALS['TSFE']->getPageAndRootline();
    $GLOBALS['TSFE']->initTemplate();
    $GLOBALS['TSFE']->tmpl->getFileName_backPath = PATH_site;
    $GLOBALS['TSFE']->forceTemplateParsing = 1;
    $GLOBALS['TSFE']->getConfigArray();
}

ありがとうVoancea!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top