<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://ngcms.ru/forum/extern.php?action=feed&amp;tid=523&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Next Generation CMS :: Форум поддержкиFYI: Постраничка комментариев в 0.9.0]]></title>
		<link>https://ngcms.ru/forum/viewtopic.php?id=523</link>
		<description><![CDATA[Самые свежие сообщения в FYI: Постраничка комментариев в 0.9.0.]]></description>
		<lastBuildDate>Wed, 24 Jun 2009 21:17:09 +0000</lastBuildDate>
		<generator>FluxBB 1.5.11</generator>
		<item>
			<title><![CDATA[FYI: Постраничка комментариев в 0.9.0]]></title>
			<link>https://ngcms.ru/forum/viewtopic.php?pid=4899#p4899</link>
			<description><![CDATA[<p><strong>/engine/includes/comments.show.php</strong><br /><strong>#1.</strong> Найти</p><div class="codebox"><pre><code>	if ($config[&#039;use_avatars&#039;]) {
		$sql = &quot;select c.*, u.avatar from &quot;.prefix.&quot;_comments c left join &quot;.uprefix.&quot;_users u on c.author_id = u.id where c.post=&quot;.db_squote($newsID).($commID?(&quot; and c.id=&quot;.db_squote($commID)):&#039;&#039;).&quot; order by c.id&quot;.($config[&#039;reverse_comments&#039;]?&#039; desc&#039;:&#039;&#039;);
	} else {
		$sql = &quot;select c.* from &quot;.prefix.&quot;_comments c WHERE c.post=&quot;.db_squote($newsID).($comment_id?(&quot; and c.id=&quot;.db_squote($comment_id)):&#039;&#039;).&quot; order by c.id&quot;.($config[&#039;reverse_comments&#039;]?&#039; desc&#039;:&#039;&#039;);
	}</code></pre></div><p><strong>#1.</strong> Заменить на</p><div class="codebox"><pre><code>	$showNumber = 30; // количество комментариев на страницу

	$cstart = intval($_REQUEST[&#039;page&#039;]) ? abs(intval($_REQUEST[&#039;page&#039;])) : 1;

	$limit_start = ($cstart - 1) * $showNumber;
	$limit_count = $showNumber;

	if ($config[&#039;use_avatars&#039;]) {
		$sql = &quot;select c.*, u.avatar from &quot;.prefix.&quot;_comments c left join &quot;.uprefix.&quot;_users u on c.author_id = u.id where c.post=&quot;.db_squote($newsID).($commID?(&quot; and c.id=&quot;.db_squote($commID)):&#039;&#039;).&quot; order by c.id&quot;.($config[&#039;reverse_comments&#039;]?&#039; desc&#039;:&#039;&#039;).($commID?&#039;&#039;:&quot; limit &quot;.$limit_start.&quot;,&quot;.$limit_count);
	} else {
		$sql = &quot;select c.* from &quot;.prefix.&quot;_comments c left join &quot;.uprefix.&quot;_users u on c.author_id = u.id WHERE c.post=&quot;.db_squote($newsID).($commID?(&quot; and c.id=&quot;.db_squote($commID)):&#039;&#039;).&quot; order by c.id&quot;.($config[&#039;reverse_comments&#039;]?&#039; desc&#039;:&#039;&#039;).($commID?&#039;&#039;:&quot; limit &quot;.$limit_start.&quot;,&quot;.$limit_count);
	}</code></pre></div><p><strong>#2.</strong> Найти</p><div class="codebox"><pre><code>		...

		exec_acts(&#039;comments&#039;, $row);
		$tpl -&gt; vars($templateName, $tvars);

		if ($commID) { echo $tpl -&gt; show($templateName); }
		$template[&#039;vars&#039;][&#039;mainblock&#039;] .= $tpl -&gt; show($templateName);
	}</code></pre></div><p><strong>#2.</strong> Добавить после</p><div class="codebox"><pre class="vscroll"><code>	$maxNavigations = 10; // количество отображаемых страниц; соответствует указанному лишь приблизительно

	// Make navigation bar
	$navigations = getNavigations(tpl_dir.$config[&#039;theme&#039;]);
	$tpl -&gt; template(&#039;pages&#039;, tpl_dir.$config[&#039;theme&#039;]);

	$which_link = &#039;full_page&#039;;

	if ($config[&#039;category_link&#039;]) {
		global $catz;
		$row[&#039;catid&#039;] = array();
		$categories = explode(&#039;-&#039;, category);
		foreach ($categories as $cat)
		{
		    $row[&#039;catid&#039;][] = $catz[$cat][&#039;id&#039;];
		}
		$row[&#039;catid&#039;] = implode(&#039;,&#039;, $row[&#039;catid&#039;]);
	} else {
		$row[&#039;postdate&#039;] = mktime(0, 0, 0, month, day, year);
	}
	$row[&#039;alt_name&#039;] = altname;

	// Prev page link
	if ($limit_start &amp;&amp; $comnum) {
		$prev = floor($limit_start / $showNumber);
		$row[&#039;page&#039;] = $prev;
		$tvars[&#039;regx&#039;][&quot;&#039;\[prev-link\](.*?)\[/prev-link\]&#039;si&quot;] = str_replace(&#039;%page%&#039;,&quot;$1&quot;,str_replace(&#039;%link%&#039;,GetLink($which_link, $row), $navigations[&#039;prevlink&#039;]));
	} else {
		$tvars[&#039;regx&#039;][&quot;&#039;\[prev-link\](.*?)\[/prev-link\]&#039;si&quot;] = &quot;&quot;;
		$no_prev = true;
	}

	$commCount = $mysql-&gt;result(&quot;SELECT count(*) as count FROM &quot;.prefix.&quot;_comments WHERE post=&quot;.db_squote($newsID).($commID?(&quot; and id=&quot;.db_squote($commID)):&#039;&#039;));
	$pages_count = ceil($commCount / $showNumber);

	$pages = &#039;&#039;;

	$sectionSize	= floor($maxNavigations / 3);
	if ($pages_count &gt; $maxNavigations) {
		// We have more than 10 pages. Let&#039;s generate 3 parts
		// Situation #1: 1,2,3,4,[5],6 ... 128
		if ($cstart &lt; ($sectionSize * 2)) {
			$pages .= generateNavigations($cstart, 1, $sectionSize * 2, $which_link, $row, $navigations);
			$pages .= $navigations[&#039;dots&#039;];
			$pages .= generateNavigations($cstart, $pages_count-$sectionSize, $pages_count, $which_link, $row, $navigations);
		} elseif ($cstart &gt; ($pages_count - $sectionSize * 2 + 1)) {
			$pages .= generateNavigations($cstart, 1, $sectionSize, $which_link, $row, $navigations);
			$pages .= $navigations[&#039;dots&#039;];
			$pages .= generateNavigations($cstart, $pages_count-$sectionSize*2 + 1, $pages_count, $which_link, $row, $navigations);
		} else {
			$pages .= generateNavigations($cstart, 1, $sectionSize, $which_link, $row, $navigations);
			$pages .= $navigations[&#039;dots&#039;];
			$pages .= generateNavigations($cstart, $cstart-1, $cstart+1, $which_link, $row, $navigations);
			$pages .= $navigations[&#039;dots&#039;];
			$pages .= generateNavigations($cstart, $pages_count-$sectionSize, $pages_count, $which_link, $row, $navigations);
		}
	} else {
		// If we have less then 10 pages
		$pages .= generateNavigations($cstart, 1, $pages_count, $which_link, $row, $navigations);
	}
	$tvars[&#039;vars&#039;][&#039;pages&#039;] = $pages;

	// Next page link
	if (($prev + 2 &lt;= $pages_count) &amp;&amp; $comnum) {
		$row[&#039;page&#039;] = $prev + 2;
		$tvars[&#039;regx&#039;][&quot;&#039;\[next-link\](.*?)\[/next-link\]&#039;si&quot;] = str_replace(&#039;%page%&#039;,&quot;$1&quot;,str_replace(&#039;%link%&#039;,GetLink($which_link, $row), $navigations[&#039;nextlink&#039;]));&quot;&lt;a href=\&quot;&quot;.GetLink($which_link, $row).&quot;\&quot;&gt;$1&lt;/a&gt;&quot;;
	} else {
		$tvars[&#039;regx&#039;][&quot;&#039;\[next-link\](.*?)\[/next-link\]&#039;si&quot;] = &quot;&quot;;
		$no_next = true;
	}

	if ($comnum &amp;&amp; ($pages_count&gt;1)){
		$tpl -&gt; vars(&#039;pages&#039;, $tvars);
		$template[&#039;vars&#039;][&#039;mainblock&#039;] .= $tpl -&gt; show(&#039;pages&#039;);
	}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (insider)]]></author>
			<pubDate>Wed, 24 Jun 2009 21:17:09 +0000</pubDate>
			<guid>https://ngcms.ru/forum/viewtopic.php?pid=4899#p4899</guid>
		</item>
	</channel>
</rss>
