简体   繁体   中英

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?


Alright another update...

I have now cleared out those styling issues and see that the underlying issue has to do with the $this variable. I have another PHP call where the view should pull data from the database like this:

<?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?


The only place that I am seeing $this defined is in the controller.php file:

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. I have created a new view that is called photos from the userdatas view. How can I go about telling the photos view to pull $this from the new database?

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. 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.

-- 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;
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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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