0

私が抱えている問題は、新しいコンポーネントを作成すると、joomla にデフォルトのレイアウト ファイルを読み取らせることができないことです。これは、コンポーネントの管理側とサイト側の両方で発生しています。私が作成した動作する別のコンポーネントと比較すると、両方のコンポーネントが同じ環境で動作するため、論理的な理由はわかりません。

サイトと管理者は同じ方法を使用しているため、一方を修正すると、もう一方が修正されるはずです。というわけで、サイト側の話です。

まずview.html.php

<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla view library
jimport('joomla.application.component.view');

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


?>

次に、tmpl/default.php

<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted Access');


// load tooltip behavior
JHtml::_('behavior.tooltip');


?>
hello

ご覧のとおり、まだ必要最小限ですが、サイトまたは管理者でアクセスしようとすると、「500: レイアウトのデフォルトが見つかりません」と表示されます。

これを引き起こした可能性のあるどこで間違ったのかを見つけようとして、n時間以上費やしました。

ここで問題になるとは思いませんが、モデル/コントローラー/コンストラクターです

component.php (実際のコンポーネントとは異なる名前)

<?php
//No direct access to this file
defined('_JEXEC') or die ('Restricted access');

// import joomla controller library
jimport('joomla.application.component.controller');

// Get an instance of the controller prefixed by GoTireReviews
$controller = JController::getInstance('Component');

// Perform the Request task
$input = JFactory::getApplication()->input;
$controller->execute($input->getCmd('task'));

// Redirect if set by the controller
$controller->redirect();

?>

models/component.php

<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla modelitem library
jimport('joomla.application.component.modelitem');

class ComponentModelComponent extends JModelItem{

}


?>

controller.php

<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla controller library
jimport('joomla.application.component.controller');

class ComponentController extends JController{

}


?>

私は目が見えず、何かを見逃しているかもしれませんが、これまでに微調整を試みるのに費やした時間を考えると、最初からやり直す方が時間のかかるアプローチではないかもしれません.

また、コンポーネントの名前は「コンポーネント」ではありませんが、この例を読みやすくするために使用しました。

編集:

その理由は、コンポーネントの名前にレビューという単語を使用したためです。これを行うと、joomla のビュー メソッドがだまされ、エラーが発生します。(それが原因かもしれないとは考えずに、これを目的としてコンポーネントの名前を変更しました)

4

1 に答える 1