0

皆さん、これは私がやろうとしていることです。インストールした joomla コンポーネントがあります。それは非常にうまく機能しますが、デフォルトのテンプレートに依存したり気にしたりすることなく、コンポーネントに独自の index.php と css をロードさせたいと考えています。

require_once ('D:\site\localsite\templates\component\index.php');

index.php では、既に css を呼び出しているので、これで問題ありません。問題は、他のすべてのデフォルト項目が、トップ メニュー、サイド メニュー、ロゴ、およびデフォルト テンプレートの他のすべてのビューに表示されることです。

私を助けてください。私はこれに髪を引っ張っています。そして、私はjoomlaに慣れていません-kohanaに慣れていました。

そして、私は tmpl=component を試しましたが、あまり効果がありません。たとえば、デフォルトのテンプレートでプリロードするすべてのものを取り除き、コンポーネントのスタッフだけを残す方法はありますか?

4

4 に答える 4

0

コンポーネントのベース ファイル ( にありますcomponents/com_yourname/yourname.php) で、設定されているコンポーネントを確認し、設定されていない場合は設定します (または設定する URL にリダイレクトします)。

$app = JFactory::getApplication();
$menu = $app->getMenu();
$jinput = $app->input;
// check if they are on the default menu item (i.e. not your component's)
// also check if the template is set already
if ($menu->getActive() == $menu->getDefault() && $jinput->get('template') != 'comtemplate') {
    // you might be able to get away with this, I haven't tested this
    $jinput->set('template', 'comtemplate');
    // otherwise set up a redirect
    // get the current url of the page
    $url = $_SERVER['REQUEST_URI'];
    // check if '?' already exists in the url
    // if it does then there is already the start of the query string so we should
    // use '&' to tack on the new query item
    // if not then start the query string with '?'
    $url .= (strpos($url, '?')===FALSE ? '?' : '&') . 'template=comtemplate';
    // take the new url and redirect to it.
    //This should update the url in the browser for the user
    $app->redirect($url);
    // since you redirected, no sense letting anything else run here, so exit
    exit();
}

更新:コードにより良いコメントを追加したので、私がやろうとしていることを理解していただければ幸いです。

于 2013-07-31T21:20:15.390 に答える