Покажите весь код модели и файла вывода
модель
<?php
// No direct access
defined( '_JEXEC' ) or die;
/**
* @author Antarey
*/
class AepetitionsModelPepitionslists extends JModelList
{
/**
* Конструктор класса
* @param Array $config
*/
public function __construct( $config = array() )
{
if ( empty( $config['filter_fields'] ) ) {
$config['filter_fields'] = array( 'title', 'state', 'ordering', 'created_by', 'created', 'id', 'author_id' );
}
parent::__construct( $config );
}
/**
* @param String $ordering
* @param String $direction
*/
protected function populateState( $ordering = null, $direction = null )
{
if ( $layout = JFactory::getApplication()->input->get( 'layout' ) ) {
$this->context .= '.' . $layout;
}
$search = $this->getUserStateFromRequest( $this->context . '.filter.search', 'filter_search' );
$this->setState( 'filter.search', $search );
$published = $this->getUserStateFromRequest( $this->context . '.filter.published', 'filter_published', '' );
$this->setState( 'filter.published', $published );
$authorId = $this->getUserStateFromRequest( $this->context . '.filter.author_id', 'filter_author_id' );
$this->setState( 'filter.author_id', $authorId );
parent::populateState( 'id', 'desc' );
}
/**
* @param string $id
* @return string
*/
protected function getStoreId( $id = '' )
{
$id .= ':' . $this->getState( 'filter.search' );
$id .= ':' . $this->getState( 'filter.published' );
$id .= ':' . $this->getState( 'filter.author_id' );
return parent::getStoreId( $id );
}
/**
* Составление запроса для получения списка записей
* @return JDatabaseQuery
*/
protected function getListQuery()
{
$query = $this->getDbo()->getQuery( true );
$query->select( 't1.id,t1.title,t1.alias,t1.asset_id,t1.introtext,t1.fulltext,t1.created,t1.publish_down,t1.ordering,t1.metakey,t1.metadesc,t1.hits'); //SEPARATOR \'<br>\'
$query->select( 't1.published as state,t1.params,t1.catid,t1.vidpovid,t1.votescount,t1.pidpucu,t1.isconfirmed,u.username as created_by,u.id as author_id, u.name as author_name,GROUP_CONCAT(up.name ) AS pidpysyname ' );
$query->from( '#__aepetitions as t1' );
$query->join( 'LEFT', '#__users AS u ON u.id = t1.created_by' );
$query->join( 'LEFT', '#__pidpysy AS p on p.aepetitions_id = t1.id' );
$query->join( 'LEFT', '#__users AS up on up.id = p.users_id' );
$query->group( 't1.id');
$published = $this->getState( 'filter.published' );
if ( is_numeric( $published ) ) {
$query->where( 't1.published=' . (int)$published );
}
$authorId = $this->getState( 'filter.author_id' );
if ( is_numeric( $authorId ) ) {
$query->where( 'u.id=' . $authorId );
}
$search = $this->getState( 'filter.search' );
if ( !empty( $search ) ) {
$search = $this->getDbo()->Quote( '%' . $this->getDbo()->escape( $search, true ). '%' );
$query->where( '(t1.title LIKE ' . $search . ' OR t1.alias LIKE ' . $search . ')' );
}
$orderCol = $this->state->get( 'list.ordering' );
$orderDirn = $this->state->get( 'list.direction' );
$query->order( $this->getDbo()->escape( $orderCol . ' ' . $orderDirn ) );
return $query;
}
/**
* Авторы записей
* @return JDatabaseQuery
*/
public function getAuthors()
{
$query = $this->getDbo()->getQuery( true );
$query->select( 'u.id AS value, u.name AS text' );
$query->from( '#__users AS u' );
$query->join( 'INNER', '#__aepetitions AS c ON c.created_by = u.id' );
$query->group( 'u.id, u.name' );
$query->order( 'u.name' );
return $this->getDbo()->setQuery( $query )->loadObjectList();
}
}
Вывод списка
<?php
/** @var $this AepetitionsViewPepitionslists */
defined( '_JEXEC' ) or die;// No direct access
JHtml::_( 'bootstrap.tooltip' );
JHtml::_( 'behavior.multiselect' );
JHtml::_( 'formbehavior.chosen', 'select' );
$user = JFactory::getUser();
$userId = $user->get( 'id' );
$listOrder = $this->escape( $this->state->get( 'list.ordering' ) );
$listDirn = $this->escape( $this->state->get( 'list.direction' ) );
$saveOrder = $listOrder == 'ordering';
if ( $saveOrder ) {
$saveOrderingUrl = 'index.php?option=com_aepetitions&task=pepitionslists.saveOrderAjax&tmpl=component';
JHtml::_( 'sortablelist.sortable', 'articleList', 'adminForm', strtolower( $listDirn ), $saveOrderingUrl );
}
$sortFields = $this->getSortFields();
?>
<script type="text/javascript">
Joomla.orderTable = function () {
var table = document.getElementById("sortTable");
var direction = document.getElementById("directionTable");
var order = table.options[table.selectedIndex].value;
if (order != '<?php echo $listOrder; ?>') {
dirn = 'asc';
} else {
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, '');
}
</script>
<form action="<?php echo JRoute::_( 'index.php?option=com_aepetitions&view=pepitionslists' ); ?>" method="post" name="adminForm" id="adminForm">
<?php if (!empty( $this->sidebar )): ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif; ?>
<?php
// Search tools bar
echo JLayoutHelper::render( 'joomla.searchtools.default', array( 'view' => $this ) );
?>
<div class="table-responsive text-left">
<table class="table table-striped" id="articleList">
<thead class="bg-info border rounded border-primary shadow-sm">
<tr>
<th width="1%">
<input type="checkbox" name="checkall-toggle" value="" title="<?php echo JText::_( 'JGLOBAL_CHECK_ALL' ); ?>" onclick="Joomla.checkAll(this)" />
</th>
<th width="2%">
<?php echo JHtml::_( 'searchtools.sort', 'JSTATUS', 'state', $listDirn, $listOrder ); ?>
</th>
<th width="10%">
<?php echo JHtml::_( 'searchtools.sort', 'COM_AEPETITIONS_PETITION_NUMBER', 'title', $listDirn, $listOrder ); ?>
</th>
<th>
<?php echo JHtml::_( 'searchtools.sort', 'COM_AEPETITIONS_INTRO_TEXT', 'introtext', $listDirn, $listOrder ); ?>
</th>
<th width="10%">
<?php echo JHtml::_( 'searchtools.sort', 'JAUTHOR', 'created_by', $listDirn, $listOrder ); ?>
</th>
<th width="10%">
<?php echo JHtml::_( 'searchtools.sort', 'COM_AEPETITIONS_CREATION_DATE', 'created', $listDirn, $listOrder ); ?>
</th>
<th width="10%">
<?php echo JHtml::_( 'searchtools.sort', 'COM_AEPETITIONS_DOWN_DATE', 'publish_down', $listDirn, $listOrder ); ?>
</th>
</tr>
</thead>
<tbody>
<?php foreach ( $this->items as $i => $item ) :
$item->max_ordering = 0;
$ordering = ( $listOrder == 'a.ordering' );
$canEdit = $user->authorise( 'core.edit', '#__aepetitions.' . $item->id );
$canCheckin = $user->authorise( 'core.manage', 'com_aepetitions' ) || $item->checked_out == $userId || $item->checked_out == 0;
$canEditOwn = $user->authorise( 'core.edit.own', '#__aepetitions.' . $item->id ) && $item->created_by == $userId;
$canChange = $user->authorise( 'core.edit.state', '#__aepetitions.' . $item->id ) && $canCheckin;
?>
<tr class="row<?php echo $i % 2; ?>">
<td class="center">
<?php echo JHtml::_( 'grid.id', $i, $item->id ); ?>
</td>
<td class="center">
<?php
$status = '';
switch ($item->state) {
case 1:
$status = '<span class="icon-file-add" title="Триває збір підписів" style="font-size:18px;color:coral;"></span>';
break;
case 2:
$status = '<span class="icon-eye-open" title="На розгляді" style="font-size:18px;color:green;"></span>';
break;
case 3:
$status = '<span class="icon-pencil" title="З відповіддю" style="font-size:18px;color:blue;"></span>';
break;
case 4:
$status = '<span class="icon-thumbs-down" title="Не підтримано" style="font-size:18px;color:red;"></span>';
break;
}
echo $status;
?>
</td>
<td>
<?php if ( $canEdit || $canEditOwn ) : ?>
<a href="<?php echo JRoute::_( 'index.php?option=com_aepetitions&task=pepitionslist.edit&id=' . $item->id ); ?>" title="<?php echo JText::_( 'JACTION_EDIT' ); ?>">
<?php echo $this->escape( $item->title ); ?></a>
<?php else : ?>
<span title="<?php echo JText::sprintf( 'JFIELD_ALIAS_LABEL', $this->escape( $item->alias ) ); ?>"><?php echo $this->escape( $item->title ); ?></span>
<?php endif; ?>
</td>
<td style="-webkit-line-clamp: 3; display: -webkit-box; -webkit-box-orient: vertical;overflow: hidden;">
<?php echo $this->escape( $item->introtext ); ?>
</td>
<td>
<?php echo $this->escape( $item->author_name ); ?>
</td>
<td>
<?php echo JHtml::_( 'date', $item->created, JText::_( 'DATE_FORMAT_LC4' ) ); ?>
</td>
<td>
<?php echo JHtml::_( 'date', $item->publish_down, JText::_( 'DATE_FORMAT_LC4' ) ); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php echo $this->pagination->getListFooter(); ?>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<?php echo JHtml::_( 'form.token' ); ?>
</div>
</form>
Форма редактирования
<?php
/** @var $this AepetitionsViewPepitionslist */
defined( '_JEXEC' ) or die;// No direct access
JHtml::_('bootstrap.tooltip');
//JHtmlBootstrap::loadCss();
JHtml::_( 'behavior.formvalidation' );
JHtml::_( 'behavior.keepalive' );
JHtml::_( 'formbehavior.chosen', 'select' );
$input = JFactory::getApplication()->input;
$needvotes = JComponentHelper::getParams('com_aepetitions')->get('needvotes');
JFactory::getDocument()->addStyleSheet('/administrator/components/com_aepetitions/media/css/bootstrap.min.css');
JFactory::getDocument()->addStyleSheet('components/com_aepetitions/media/css/aeadm.css');
?>
<script type="text/javascript">
Joomla.submitbutton = function (task) {
if (task == 'pepitionslist.cancel' || document.formvalidator.isValid(document.id('item-form'))) {
<?php echo $this->form->getField( 'text' )->save(); ?>
Joomla.submitform(task, document.getElementById('item-form'));
} else {
alert('<?php echo $this->escape( JText::_( 'JGLOBAL_VALIDATION_FORM_FAILED' ) ); ?>');
}
}
</script>
<form action="<?php echo JRoute::_( 'index.php?option=com_aepetitions&id=' . $this->form->getValue( 'id' ) ); ?>" method="post" name="adminForm" id="item-form" class="form-validate" enctype="multipart/form-data">
<div class="form-horizontal">
<div class="form-row d-flex d-md-flex flex-row justify-content-md-start align-items-md-center" style="margin: 4px 0;">
<div class="col" style="padding: 4px 16px">
<button onclick="Joomla.submitbutton('pepitionslist.cancel');" class="btn btn-small button-cancel">
<span class="icon-cancel" aria-hidden="true"></span><?php echo JText::_( 'JTOOLBAR_CLOSE');?></button>
</div>
</div>
<div class="form-row d-flex d-md-flex flex-row justify-content-md-start align-items-md-center border border-primary rounded" style="margin: 4px 0;">
<div class="col-md-6" style="padding: 4px 16px">
<label for="jform_alias"><?php echo JText::_( 'COM_AEPETITIONS_NUMBER');?></label>
<?php echo $this->form->getInput( 'alias' );?>
</div>
<div class="col-md-6" style="padding: 4px 16px;">
<label for="jform_created_by"><?php echo JText::_( 'COM_AEPETITIONS_AUTOR');?></label>
<?php echo $this->form->getInput( 'created_by' );?>
</div>
</div>
<div class="form-row d-flex flex-row border border-primary rounded" style="margin: 4px 0;">
<div class="col d-md-flex flex-column">
<div class="form-row d-flex d-md-flex flex-column flex-fill" style="padding: 4px 16px">
<label for="jform_created"><?php echo JText::_( 'COM_AEPETITIONS_CREATION_DATE');?></label>
<?php echo $this->form->getInput( 'created' );?>
</div>
<div class="form-row d-flex d-md-flex flex-column flex-fill" style="padding: 4px 16px">
<label for="jform_publish_down"><?php echo JText::_( 'COM_AEPETITIONS_DOWN_DATE');?></label>
<?php echo $this->form->getInput( 'publish_down' );?>
</div>
</div>
<div class="col">
<div class="form-row">
<div class="col-md-6" style="padding: 4px 16px;">
<label for="needvotes"><?php echo JText::_( 'COM_AEPETITIONS_NEEDVOTES');?></label>
<input class="form-control" type="number" id="needvotes" readonly="" value="<?php echo $needvotes;?>">
</div>
<div class="col-md-6" style="padding: 4px 16px;">
<label for="jform_votescount"><?php echo JText::_( 'COM_AEPETITIONS_VOTES');?></label>
<?php echo $this->form->getInput( 'votescount' );?>
</div>
</div>
</div>
</div>
<div class="form-row d-flex flex-row border border-primary rounded" style="margin: 4px 0;">
<div class="col-8 d-flex flex-column" style="padding: 4px 16px;">
<label for="jform_introtext"><?php echo JText::_( 'COM_AEPETITIONS_AINTRO');?></label>
<?php echo $this->form->getInput( 'introtext' );?>
<label for="jform_fulltext"><?php echo JText::_( 'COM_AEPETITIONS_AFULL');?></label>
<?php echo $this->form->getInput( 'fulltext' );?>
</div>
<div class="col-4" style="padding: 4px 16px;">
<label for="jform_pidpucu_name"><?php echo JText::_( 'COM_AEPETITIONS_PIDPYSY');?></label>
<?php echo $this->form->getInput( 'pidpysyname' );?>
</div>
</div>
</div>
<input type="hidden" name="task" value="" />
<input type="hidden" name="return" value="<?php echo $input->getCmd( 'return' ); ?>" />
<?php echo JHtml::_( 'form.token' ); ?>
</form>