9

自分のコンポーネント(view.html.php)にビュー(フロントエンド)があります:

class MevViewMev extends JView{
        function display($tpl = null){
                parent::display($tpl);
        }
}

そしてテンプレート:

<?php defined('_JEXEC') or die('Restricted access'); ?>
<div>
ASFADSFDSF
</div>

joomlaテンプレートなしで表示する方法(ヘッドセクション、スタイルなど)。ウィンドウでjqueryonclickメソッドのこの部分を呼び出したいと思います。

4

3 に答える 3

21

コンポーネントのみを表示するには、「tmpl=component」パラメーターを url に追加します。コンポーネントのビュー以外のものを表示する必要がある場合は、カスタマイズできます。テンプレートのルート フォルダーに「component.php」ファイルを作成し、必要なものを含めます。テンプレートのルート フォルダーに "some_template.php" を作成し、"tmpl=some_template" パラメーターを URL に追加します。

于 2011-12-17T16:42:08.267 に答える
4

編集開始

OKなので、以下は機能しますが、より良い方法を見つけました。あなたのコントローラーで...

if (JRequest::getVar('format') != 'raw') {
    $url = JURI::current() . '?' . $_SERVER['QUERY_STRING'] . '&format=raw';
    header('Location: ' . $url);
    // or, if you want Content-type of text/html just use ...
    // redirect($url);
}

編集を終了

Babur Usenakunov によって提案されているように、「tmpl」を「component」に設定できます。この場合、次のようにスクリプトと css をロードできます。

JRequest::setVar('tmpl','component');

ただし、生の出力を作成する場合は、 &format=raw を追加するか、コンポーネントで「生」タイプのビューを作成します ...

残念ながら、raw render の viewType を正しく作成する唯一の機能的な方法は、view クラスが parent::display() を呼び出した後に exit() を呼び出すことです ...

あなたのcontroller.phpで...

class com_whateverController() extends JController
{
    function __construct()
    {
        // the following is not required if you call exit() in your view class (see below) ...
        JRequest::setVar('format','raw');
        JFactory::$document = null;
        JFactory::getDocument();
        // or
        //JFactory::$document = JDocument::getInstance('raw');
        parent::__construct();
    }

    function display()
    {
        $view = $this->getView('whatever', 'raw');
        $view->display();
    }

}

次に、views/whatever/view.raw.php で ...

class com_whateverViewWhatever extends JView
{
    public function display($tpl = null)
    {
            parent::display();
            exit; // <- if you dont have this then the output is captured in and output buffer and then lost in the rendering
    }
}
于 2013-10-22T17:26:37.790 に答える