2

内部リンクのあるニュース記事があります。RTEには、次のようなリンクがあります。

http://www.yourdomain.com/?id=3

HTMLテキストモードで。問題は、このリンクがフロントエンドにも表示されることです。RealURLは、このリンクを次のようなものに変換する必要があります

http://www.yourdomain.com/products/

RTEのコンテンツは現在このように解析されています

$parseObj = t3lib_div::makeInstance('t3lib_parsehtml_proc'); 
$txt = $parseObj->TS_links_rte($result['bodytext']);
$txt = $parseObj->TS_transform_rte($txt);

私はこのようなものを使うべきだと読みました

$pObj = t3lib_div::makeInstance('tslib_pibase');
$txt = $pObj->pi_RTEcssText($result['bodytext']);

しかし、どうすればこの機能にアクセスできるのかわかりません。私は得る

Fatal error: Call to a member function parseFunc() on a non-object in /home/myuser/www/home/typo3/sysext/cms/tslib/class.tslib_pibase.php on line 1384

これを行う正しい方法は何ですか?関数にアクセスするにはどうすればよいpi_RTEcssTextですか?クラスを使用する必要がありますか?クラスなしでそれを行う他の方法はありますか?

編集:

TemplaVoilaを使用して新しいテンプレートを作成し、lib.newscontentTSオブジェクトパスとして定義しました。

TSメインテンプレート

includeLibs.user_news = fileadmin/templates/php_scripts/news/class.news.php

lib.newscontent = USER_INT
lib.newscontent {
  userFunc = user_news->main
  userFunc.bodytext.parseFunc < lib.parseFunc_RTE
}  

class.news.php

<?

class user_news {

    var $cObj;

    private $conf;

    function main($content,$conf) {
        $this->conf = $conf; 
        $this->setPreferences();        
        $content .= $this->aktuelleNews();

        return $content;
    }

    private function aktuelleNews() {
        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
                '*',         // SELECT ...
                'tt_news',     // FROM ...
                'pid=22 AND deleted=0 AND hidden=0',    // WHERE...
                '',            // GROUP BY...
                'datetime DESC'    // ORDER BY...
        );

        $i = 1;
        $out_list = '<ul id="news">';
        while ($data = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
            $date = date("d.m.Y",$data['datetime']);
            $out_list .= '<li><a href="#section'.$i.'">'.$date.': '.$data['title'].'</a></li>';
            $out_detail.= $this->outputnewsdetail($data,$i);

            $i++;
        }
        $out_list .= '</ul>';
        return $out_list . $out_detail;
    }

    private function outputnewsdetail($result,$count){
        $this->cObj->start($result, 'tt_news');

        $bodytext = $this->cObj->stdWrap($result['bodytext'], $this->conf['bodytext']);
        $bodytext = $this->cObj->parseFunc($bodytext,$GLOBALS['TSFE']->tmpl->setup['lib.']['parseFunc_RTE.']);

        return $bodytext;

    }

    private function setPreferences() {

    }

}
?>

localconf.php

include(PATH_site.'fileadmin/templates/php_scripts/news/class.news.php');

残りの質問

TSメインテンプレートのレンダリング部分が機能しないのはなぜですか?使用しました

$this->cObj->parseFunc($bodytext,$GLOBALS['TSFE']->tmpl->setup['lib.']['parseFunc_RTE.']);

私の結果を得るために。

4

1 に答える 1

1

を好む:

$txt = $this->cObj->stdWrap($result['bodytext'], $this->conf['bodytext.']);

メインメソッドに必要なもの:$ this-> conf = $ conf;

TypoScriptで、parseFuncを本文に追加します。

 plugin.tx_yourplugin_pi1 {
    bodytext.parseFunc < lib.parseFunc_RTE
 }

主なアイデアは、コンテンツ要素によって使用される通常のparseFuncを使用することです。したがって、同じレンダリングがあります。もう1つの利点は、アプリケーションがより柔軟になることです。

補足として。そのためにlokalcObjを作成し、完全なデータを渡すことは価値があります。したがって、TypoScriptですべてのフィールドを使用できます。あなたの場合、Feフィールド=本文。

# create lokal cObj - do not override the original data!
$cObj = t3lib_div::makeInstance('tslib_cObj');
foreach ($row = ...) {
   # override data array with row. Every field in $row is now accesible via 
   # TypoScript field = fieldname
   $cObj->start($row, $tableName);
   $content .= $cObj->stdWrap($row['bodytext'], $this->conf['bodytext.']);
}

# TS Setup:
# in your case you could do somesthing like:
plugin.tx_yourplugin_pi1 {
    bodytext.parseFunc < lib.parseFunc_RTE
    bodytext.wrap = <div class="hide">|</div>
    bodytext.prepend = TEXT
    bodytext.prepend.field = bodytext
    bodytext.prepend.stripHtml = 1
    bodytext.prepend.crop = 30 | ... | 1
    bodytext.prepend.wrap = <span title="|" onclick="showBodytext()">info</span>
}

ユーザー関数で必要な場合は、次のようにしてみてください。

function user_yourfunction($content,$conf) {
    $result = *magic*
    $cObj = t3lib_div::makeInstance('tslib_cObj');
    $cObj->start($result, 'your table name');
    return $cObj->stdWrap($result['bodytext'], $conf['bodytext.']);
}

TypoScriptの場合:

includeLibs.something = media/scripts/example_callfunction.php
page.10 = TEXT
page.10 {
   value = Hello World
   postUserFunc = user_yourfunction
   postUserFunc.bodytext.parseFunc < lib.parseFunc_RTE
}
于 2012-09-05T07:40:09.823 に答える