简体   繁体   English

将Search DIV添加到Joomla 3.0组件视图时,CSS丢失

[英]CSS is Lost when adding Search DIV to Joomla 3.0 Component View

I have found that when this code snippet is added to the view of a custom component that I am creating then I am losing the default styling from the admin panel. 我发现当将此代码段添加到我正在创建的自定义组件的视图中时,我从管理面板中丢失了默认样式。

        <div class="btn-group pull-right hidden-phone">
            <label for="limit" class="element-invisible"><?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC');?></label>
            <?php echo $this->pagination->getLimitBox(); ?>
        </div>

Any ideas as to why that could be happening? 为什么会发生这种情况的任何想法?


I have also found that this code is dropping styling as well on the same view: 我还发现该代码也在同一视图上删除样式:

<?php echo $this->pagination->getListFooter(); ?>

This makes me think that it has something to do with the $this->pagination where is this typically defined for a view? 这使我认为它与$this->pagination ,这通常是为视图定义的?


Alright another update... 好吧另一个更新...

I have now cleared out those styling issues and see that the underlying issue has to do with the $this variable. 现在,我已经清除了那些样式问题,并看到基本问题与$this变量有关。 I have another PHP call where the view should pull data from the database like this: 我有另一个PHP调用,其中视图应从数据库中提取数据,如下所示:

<?php foreach ($this->items as $i => $item) :
            $ordering   = ($listOrder == 'a.ordering');
            $canCreate  = $user->authorise('core.create',       'com_bbmaps');
            $canEdit    = $user->authorise('core.edit',         'com_bbmaps');
            $canCheckin = $user->authorise('core.manage',       'com_bbmaps');
            $canChange  = $user->authorise('core.edit.state',   'com_bbmaps');
            ?>

But again, I see errors--> 但是我再次看到错误->

Warning: Invalid argument supplied for foreach()

Ultimately my question is where do I define the database that $this relates to? 最终,我的问题是我在哪里定义与$this相关的数据库?


The only place that I am seeing $this defined is in the controller.php file: 我看到的唯一定义$this地方是controller.php文件:

public function display($cachable = false, $urlparams = false)
{
    require_once JPATH_COMPONENT.'/helpers/componenthelper.php';

    $view       = JFactory::getApplication()->input->getCmd('view', 'userdatas');
    JFactory::getApplication()->input->set('view', $view);

    parent::display($cachable, $urlparams);

    return $this;
}

As you can see it is referencing the userdatas view. 如您所见,它引用了userdatas视图。 I have created a new view that is called photos from the userdatas view. 我创建了一个新视图,该视图从userdatas视图中称为photos How can I go about telling the photos view to pull $this from the new database? 如何告诉photos视图从新数据库中提取$this

Please check if you closed all the opened tags. 请检查是否关闭了所有打开的标签。 I've had the same problem when I forgot to close some previously opened or other tag. 当我忘记关闭一些先前打开的标签或其他标签时,我遇到了同样的问题。 Sometimes the closing is mistakenly replaced with a by some editors' autocomplete functionality. 有时,某些编辑者的自动完成功能会误将结束符替换为。

-- EDIT -- -编辑-

Please also check your server's error log if you hadn't enabled the php.ini display_errors directive. 如果您尚未启用php.ini display_errors指令,也请检查服务器的错误日志。 There could be an error in your component which you don't see on the page. 您的组件中可能有一个错误,您没有在页面上看到。 When there is a "fatal" PHP error the execution is stopped, so is stopped the further rendering. 当出现“致命” PHP错误时,将停止执行,因此将停止进一步的渲染。

-- SECOND EDIT -- -第二编辑-

You could try to replace the following: 您可以尝试替换以下内容:

<?php foreach ($this->items as $i => $item) :

with: 与:

<?php if (!empty($this->items) :
          foreach ($this->items as $i => $item) :

and then close the "if" after the "endforeach": 然后在“ endforeach”之后关闭“ if”:

    endforeach;
endif;

This should fix the "invalid argument" error. 这应该修复“无效参数”错误。

PS: In this scenario $this will most probably correspond to the template object which has all the properties that are assigned for it to use. PS:在这种情况下,$ this很可能对应于模板对象,该模板对象具有为其分配的所有要使用的属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM