好了,伙计们,这是我们要做的。我已经安装了joomla组件。它运行得很好,但是现在我希望组件加载自己的index.php和css,而不必依赖或关心默认的模板。我已经创建了一个组件/view/dafault.php,并在其中调用了
require_once ('D:\site\localsite\templates\component\index.php');
在index.php中,我已经调用了css,所以这是可以的。问题是,所有其他默认项目都进入视图--顶部菜单、侧菜单、徽标和默认模板的其他所有内容。
请帮帮我。我在这件事上拉着妈妈的头发。我对乔姆拉很陌生--已经习惯了科哈纳。
而且我也尝试过tmpl=component,但它做得不多。是否有一种方法可以消除所有预加载的内容,例如在默认模板上,而只留下组件人员?
发布于 2013-07-31 21:20:15
在组件的基本文件(位于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-27 09:29:50
如果我不理解你的问题,你可以这样做;
<?php if ($this->countModules( 'position-1' )) : ?>
<div class="cssforthecomponent">
<jdoc:include type="component" />
</div>
<?php else: ?>
<?php if ($this->countModules( 'position-2' )) : ?>
<div class="cssfortherestofwebsite">
<jdoc:include type="component" />
</div>
<?php endif; ?>将组件分配给一个带有空模块的菜单项,将同一菜单项的位置-1分配给菜单项。看起来不错。你不需要为此包括或做其他的事情。
和平..。
发布于 2013-07-27 22:31:08
您可以这样调用组件:
index.php?option=com_your_component&format=raw也可以为组件添加菜单项,并禁用此菜单项的所有模块分配。
https://stackoverflow.com/questions/17888115
复制相似问题