Javascript-форум (https://javascript.ru/forum/)
-   Серверные языки и технологии (https://javascript.ru/forum/server/)
-   -   Проблема с пагинацией (https://javascript.ru/forum/server/50866-problema-s-paginaciejj.html)

november 14.10.2014 23:55

Проблема с пагинацией
 
Доброго времени суток. Есть несколько сайтов. Хочу перебросить пагинацию с одного - на другой.
Есть такой код:
my $curpage	= $NUMBER{page} || 1;
my $id = $NUMBER{id};
$id =~ s/^0// while $id =~ /^0/;

if (@items) {
		my $count = @items;
		my $count_from = ($curpage-1)*$items_on_top;
		my $count_to = $count_from+$items_on_top;
		$count_to = $count if ($count<$count_to);
		my @items = @items[$count_from .. ($count_to-1)];
		if (@items) {
			push(@items, {sp=>1}) while (@items/$items_per_line-int(@items/$items_per_line) != 0);
			while (@items>0) {
				my @it = splice(@items, 0, $items_per_line);
				$it[0]->{first} = 1;
				$it[-1]->{last} = 1;
				push(@{$hash->{items}}, {it=>\@it});
			}
		}
		if ($count>$items_on_top) {
			my $pages = (int($count/$items_on_top))+(($count%$items_on_top)>0?1:0);
			$hash->{nav} = &navigation($curpage, $pages, 10);
		}	
	}

И далее вывожу на сайт вот так:
^[?nav
^[@nav
^[?_arrow  ]?[
	^[?_active <span style="color:#1b0104;background-color:#d4c397;">&nbsp;^[$id]&nbsp;</span>]?[ <a href="/ourworks^[$id]^[?::year _y^[$::year]]?[^[?::archive _arch?]?].html">^[?int <span class="tpages">^[?_first &nbsp;^[$id]&nbsp;]?[^[$id]?]</span>]?[^[$id]?]</a> ?]<!-- ^[?_last ]?[|?] -->
?]
@]
]?[&nbsp;?]


Но, не работает. Суть такая, что должен показывать страницы с 1 по 10, а затем каждую десятую, т.е. 11,21,31 и тд. Но он полностью игнорирует мои условия и показывает все страницы.

Что я делаю не так? Может я еще и не тот кусок кода показал? :)


Часовой пояс GMT +3, время: 08:10.