Новости Joomla

0 Пользователей и 1 Гость просматривают эту тему.
  • 14 Ответов
  • 2609 Просмотров
*

HomeDirect

  • Осваиваюсь на форуме
  • 21
  • 0 / 0
Random listing в категориях
« : 17.02.2011, 00:18:26 »
Может я где то, что то упустил, но как сделать обычный рандом листинг в категории, который регулярно менял расположение итемов при обновление страницы.
Очень нужна опция простого рандома итемов в категории, а в общем макете рандомов есть несколько вариантов, только не обычный почему то.
*

effrit

  • Moderator
  • 10132
  • 1118 / 13
  • effrit.com
Re: Random listing в категориях
« Ответ #1 : 17.02.2011, 09:35:53 »
открываем
components\com_flexicontent\templates\ТУТ_НАЗВАНИЕ_ШАБЛОНА\category_items.php

ищём

$items   = $this->items;

добавляем ниже

shuffle ($items);

*

HomeDirect

  • Осваиваюсь на форуме
  • 21
  • 0 / 0
Re: Random listing в категориях
« Ответ #2 : 17.02.2011, 19:33:44 »
Что то не найду точной фразы кода хм, вот сам код
Код
<?php
/**
 * @version 1.5 stable $Id: category_items.php 283 2010-06-12 08:40:34Z emmanuel.danan $
 * @package Joomla
 * @subpackage FLEXIcontent
 * @copyright (C) 2009 Emmanuel Danan - www.vistamedia.fr
 * @license GNU/GPL v2
 *
 * FLEXIcontent is a derivative work of the excellent QuickFAQ component
 * @copyright (C) 2008 Christoph Lukes
 * see www.schlu.net for more information
 *
 * FLEXIcontent is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

defined( '_JEXEC' ) or die( 'Restricted access' );
// first define the template name
$tmpl = $this->tmpl;
?>
<script type="text/javascript">
function tableOrdering( order, dir, task )
{
var form = document.getElementById("adminForm");

form.filter_order.value = order;
form.filter_order_Dir.value = dir;
document.getElementById("adminForm").submit( task );
}
</script>

<?php if ((($this->params->get('use_filters', 0)) && $this->filters) || ($this->params->get('use_search')) || ($this->params->get('show_alpha', 1))) : ?>
<form action="<?php echo $this->action; ?>" method="post" id="adminForm">
<?php if ((($this->params->get('use_filters', 0)) && $this->filters) || ($this->params->get('use_search'))) : ?>
<div id="fc_filter" class="floattext">
<?php if ($this->params->get('use_search')) : ?>
<div class="fc_fleft">
<input type="text" name="filter" id="filter" value="<?php echo $this->lists['filter'];?>" class="text_area" onchange="document.getElementById('adminForm').submit();" />
<button onclick="document.getElementById('adminForm').submit();"><?php echo JText::_( 'FLEXI_GO' ); ?></button>
<button onclick="document.getElementById('filter').value='';document.getElementById('adminForm').submit();"><?php echo JText::_( 'FLEXI_RESET' ); ?></button>
</div>
<?php endif; ?>
<?php if ($this->filters) : ?>
<div class="fc_fright">
<?php
foreach ($this->filters as $filt) :
echo '<span class="filter">';
echo "<b>Выбор по региону  </b>  ". $filt->html;
echo '</span>';
endforeach;
?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php
if ($this->params->get('show_alpha', 1)) :
echo $this->loadTemplate('alpha');
endif;
?>
<input type="hidden" name="option" value="com_flexicontent" />
<input type="hidden" name="filter_order" value="<?php echo $this->lists['filter_order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="" />
<input type="hidden" name="view" value="category" />
<input type="hidden" name="letter" value="" id="alpha_index" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="id" value="<?php echo $this->category->id; ?>" />
</form>
<?php endif; ?>

<?php
if ($this->items) :
// routine to determine all used columns for this table
$layout = $this->params->get('clayout', 'default');
$fbypos = flexicontent_tmpl::getFieldsByPositions($layout, 'category');
$columns = array();
foreach ($this->items as $item) :
if (isset($item->positions['table'])) :
foreach ($fbypos['table']->fields as $f) :
if (!in_array($f, $columns)) :
$columns[$f] = @$item->fields[$f]->label;
endif;
endforeach;
endif;
endforeach;
?>
<table id="flexitable" class="flexitable" width="100%" border="0" cellspacing="0" cellpadding="0" summary="<?php echo $this->category->name; ?>">
<thead>
<tr>
<th id="flexi_title" scope="col"><?php echo JText::_( 'FLEXI_ITEMS' ); ?></th>

<?php foreach ($columns as $name => $label) : ?>
<th id="field_<?php echo $name; ?>" scope="col"><?php echo $label; ?></th>
<?php endforeach; ?>

</tr>
</thead>

<tbody>

<?php foreach ($this->items as $item) : ?>                         
  <tr class="sectiontableentry">

<!-- BOF item title -->
    <th scope="row" class="table-titles">
    <?php if ($this->params->get('link_titles', 0)) : ?>
    <a href="<?php echo JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $this->category->slug)); ?>"><?php echo $this->escape($item->title); ?></a>
    <?php
    else :
    echo $this->escape($item->title);
    endif;
    ?>
</th>
<!-- BOF item title -->

<!-- BOF fields -->
<?php foreach ($columns as $name => $label) : ?>
<td><?php echo isset($item->positions['table']->{$name}->display)? $item->positions['table']->{$name}->display : ''; ?></td>
<?php endforeach; ?>
<!-- EOF fields -->

</tr>
<?php endforeach; ?>

</tbody>
</table>
<?php else : ?>
<div class="noitems"><?php echo JText::_( 'FLEXI_NO_ITEMS_CAT' ); ?></div>
<?php endif; ?>

есть это, но
Код
$tmpl = $this->tmpl;
но это кажись не то.
*

effrit

  • Moderator
  • 10132
  • 1118 / 13
  • effrit.com
Re: Random listing в категориях
« Ответ #3 : 17.02.2011, 20:18:10 »
да, там же несколько шаблонов разных ).
способ работает, кстати, но только при отрубленном кэшировании
*

effrit

  • Moderator
  • 10132
  • 1118 / 13
  • effrit.com
Re: Random listing в категориях
« Ответ #4 : 17.02.2011, 20:20:34 »
ищём вот это

if ($this->items) :
   // routine to determine all used columns for this table

и ДО него вставляем

   shuffle ($this->items);
*

HomeDirect

  • Осваиваюсь на форуме
  • 21
  • 0 / 0
Re: Random listing в категориях
« Ответ #5 : 17.02.2011, 20:32:53 »
Ааа супер спасибо получилось, а то я После вставлял, ругается )
*

effrit

  • Moderator
  • 10132
  • 1118 / 13
  • effrit.com
*

HomeDirect

  • Осваиваюсь на форуме
  • 21
  • 0 / 0
Re: Random listing в категориях
« Ответ #7 : 17.02.2011, 20:36:31 »
ммм чистый рандом, а упорядоченный можно сделать?
Тоже рандом ,но по порядку...или я зажрался? :laugh:
*

HomeDirect

  • Осваиваюсь на форуме
  • 21
  • 0 / 0
Re: Random listing в категориях
« Ответ #8 : 17.02.2011, 20:38:55 »
А какой большой объем инфы может быть из 10-20 итемов в категории, там же только описание небольшое ну и картинка на крайний случай.
*

effrit

  • Moderator
  • 10132
  • 1118 / 13
  • effrit.com
Re: Random listing в категориях
« Ответ #9 : 17.02.2011, 20:41:56 »
ну с таким количеством проблем не должно быть

))
это что ещё за новое слово в программировании: "упорядоченный рандом" ?

*

HomeDirect

  • Осваиваюсь на форуме
  • 21
  • 0 / 0
Re: Random listing в категориях
« Ответ #10 : 17.02.2011, 20:45:12 »
это значит, что щас рандом происходит в разброс, а хотелось бы по очереди.
*

effrit

  • Moderator
  • 10132
  • 1118 / 13
  • effrit.com
Re: Random listing в категориях
« Ответ #11 : 17.02.2011, 20:48:28 »
ну нафиг.
читай мануалы по php. а то свяжешься с таким, потом сам начнёшь упорядоченный рандом придумывать ))).
*

HomeDirect

  • Осваиваюсь на форуме
  • 21
  • 0 / 0
Re: Random listing в категориях
« Ответ #12 : 17.02.2011, 20:50:01 »
Кстати есть один не приятный момент в Флэкси, его Google некоторые страницы категорий в чистом виде паразит находит без шаблона, не приятно как то выглядит, но это я думаю другая тема.
*

HomeDirect

  • Осваиваюсь на форуме
  • 21
  • 0 / 0
Re: Random listing в категориях
« Ответ #13 : 17.02.2011, 20:52:02 »
Не лан лан не ругайси яж не настаиваю спасибо и за это. Просто клиенты привередливые))
*

effrit

  • Moderator
  • 10132
  • 1118 / 13
  • effrit.com
Re: Random listing в категориях
« Ответ #14 : 17.02.2011, 20:58:18 »
я знаю, что клиенты любят моз кушать чужой, но ты то от них не должен заражаться этой нехорошей привычкой )
хочешь результат - должен ставить нормально задачу.
по твоему невнятному "упорядоченному рандому" никто никогда тебе ничего не сделает.
это форум. тут надо думать кратко, быстро и конкретно.
а которые думают по другому - остаются наедине с собой и съедают собственный мозг от безисходности ))
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться