首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >joomla组件:如何删除所有预加载的数据和css

joomla组件:如何删除所有预加载的数据和css
EN

Stack Overflow用户
提问于 2013-07-26 18:07:52
回答 4查看 382关注 0票数 0

好了,伙计们,这是我们要做的。我已经安装了joomla组件。它运行得很好,但是现在我希望组件加载自己的index.php和css,而不必依赖或关心默认的模板。我已经创建了一个组件/view/dafault.php,并在其中调用了

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

在index.php中,我已经调用了css,所以这是可以的。问题是,所有其他默认项目都进入视图--顶部菜单、侧菜单、徽标和默认模板的其他所有内容。

请帮帮我。我在这件事上拉着妈妈的头发。我对乔姆拉很陌生--已经习惯了科哈纳。

而且我也尝试过tmpl=component,但它做得不多。是否有一种方法可以消除所有预加载的内容,例如在默认模板上,而只留下组件人员?

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2013-07-31 21:20:15

在组件的基本文件(位于components/com_yourname/yourname.php)中,如果没有设置组件,您可能希望检查正在设置的组件,然后设置它(或者重定向到设置它的url ):

代码语言:javascript
复制
$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();
}

更新:我在代码中添加了更好的注释,希望您能够看到我想做的事情。

票数 0
EN

Stack Overflow用户

发布于 2013-07-27 09:29:50

如果我不理解你的问题,你可以这样做;

代码语言:javascript
复制
<?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分配给菜单项。看起来不错。你不需要为此包括或做其他的事情。

和平..。

票数 0
EN

Stack Overflow用户

发布于 2013-07-27 22:31:08

您可以这样调用组件:

代码语言:javascript
复制
index.php?option=com_your_component&format=raw

也可以为组件添加菜单项,并禁用此菜单项的所有模块分配。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17888115

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档