ssi_boardNews sayfalama yapımı

Started by cee山, March 21, 2014, 02:45:05 PM

Previous topic - Next topic

cee山

iyi günler ssi_boardNews ile sayfalama yapımı.
boş bir php sayfası oluşturalım arkadaşlar ben ismini portal.php koydum örnekte ona göredir
içine alttaki kodu yapıştıralım

<?php
require_once('SSI.php');
require_once(
'Portaladmin.php');

$page = !empty($_GET['page']) ? $_GET['page'] : 1;
$news = ssi_boardNews(95, 100, null,300,'array');
$pagination = new Breeze_Pagination($news, $page, '', '', 5, 5);
$pagination->PaginationArray();
$pagtrue = $pagination->PagTrue();
$data = $pagination->OutputArray();
foreach ($data as $news)
{
echo '
<div class="news_item">
<h3 class="news_header">

<a href="'
, $news['href'], '">', $news['subject'], '</a>
</h3>
<div class="news_timestamp">'
, $news['time'], ' ', $txt['by'], ' ', $news['poster']['link'], '</div>
<div class="news_body" style="padding: 2ex 0;">'
, $news['body'], '</div>
'
, $news['link'], $news['locked'] ? '' : ' | ' . $news['comment_link'], '
</div>'
;


echo '
<hr />'
;
}
echo'<br/><center>';
echo $pagination->OutputPanel();
       echo
'</center>';
?>

şimdi yeni bir php dosyası oluşturalım adınıda Portaladmin.php koyalım
Daha sonra bu kodları ekliyoruz.

<?php
class Breeze_Pagination
{
public function __construct($array, $page = 1, $link_prefix = false, $link_suffix = false, $limit_page = 20, $limit_number = 10)
{
if (empty($array))
$this->UsedArray = array();

else
{
$this->UsedArray = $array;
$this->Page = !empty($page) || !$limit_page ? $page : 1;
$this->LinkPrefix = !empty($link_prefix) ? $link_prefix : '';
$this->LinkSufflix = !empty($link_sufflix) ? $link_sufflix : '';
$this->LimitPage = !empty($limit_page) ? $limit_page : 20;
$this->LimitNumber = !empty($limit_number) ? $limit_number : 20;
$this->panel = '';
$this->output = array();
$this->page_cur = '';
}
}

public function PaginationArray()
{
$this->num_rows = count($this->UsedArray);

if (!$this->num_rows or $this->LimitPage >= $this->num_rows)
{
$this->pagtrue = false;
return;
}

$this->num_pages = ceil($this->num_rows / $this->LimitPage);
$this->page_offset = ($this->Page - 1) * $this->LimitPage;

/* Calculating the first number to show */
if ($this->LimitNumber)
{
$this->limit_number_start = $this->Page - ceil($this->LimitNumber / 2);
$this->limit_number_end = ceil($this->Page + $this->LimitNumber / 2) - 1;

if ($this->limit_number_start < 1)
$this->limit_number_start = 1;

//In case if the current page is at the beginning.
$this->dif = ($this->limit_number_end - $this->limit_number_start);

if ($this->dif < $this->LimitNumber)
$this->limit_number_end = $this->limit_number_end + ($this->LimitNumber - ($this->dif + 1));

if ($this->limit_number_end > $this->num_pages)
$this->limit_number_end = $this->num_pages;

//In case if the current page is at the ending.
$this->dif = ($this->limit_number_end - $this->limit_number_start);

if ($this->limit_number_start < 1)
$this->limit_number_start = 1;
}

else
{
$this->limit_number_start = 1;
$this->limit_number_end = $this->num_pages;
}

/* Let's generate the panel */
$this->GeneratePageLinks();
$this->NavigationArrows();
$this->panel = trim($this->panel);

$this->output['panel'] = $this->panel; //Panel HTML source.
$this->output['offset'] = $this->page_offset; //Current page number.
$this->output['limit'] = $this->LimitPage; //Number of resuts per page.
$this->output['array'] = array_slice($this->UsedArray, $this->page_offset, $this->LimitPage, true); //Array of current page results.

$this->pagtrue = true;
}

/* Generating page links. */
private function GeneratePageLinks()
{
for ($i = $this->limit_number_start; $i <= $this->limit_number_end; $i++)
{
$this->page_cur = '<a href="portal.php?page='. $this->LinkPrefix . $i . $this->LinkSufflix. '">'. $i .'</a>';

if ($this->Page == $i)
$this->page_cur = '<strong>'. $i .'</strong>';

else
$this->page_cur = '<a href="portal.php?page='. $this->LinkPrefix . $i . $this->LinkSufflix .'">'. $i .'</a>';

$this->panel .= ' <span>'. $this->page_cur .'</span>';
}
}

/* Navigation arrows. */
private  function NavigationArrows()
{
if ($this->limit_number_start > 1)
$this->panel = '<strong><a href="portal.php?page='. $this->LinkPrefix . (1) . $this->LinkSufflix .'">&lt;&lt;</a>  <a href="portal.php?page='. $this->LinkPrefix . ($this->Page - 1) . $this->LinkSufflix .'">&lt;</a></strong>'. $this->panel;

if ($this->limit_number_end < $this->num_pages)
$this->panel = $this->panel .' <strong><a href="portal.php?page='. $this->LinkPrefix . ($this->Page + 1) . $this->LinkSufflix .'">&gt;</a> <a href="portal.php?page='. $this->LinkPrefix . $this->num_pages . $this->LinkSufflix .'">&gt;&gt;</a></strong>';
}

public function OutputArray()
{
if(!empty($this->output['array']))
return $this->output['array'];

else
return false;
}

public function OutputPanel()
{
if(!empty($this->output['panel']))
return $this->output['panel'];

else
return false;
}

public function OutputOffSet()
{
if(!empty($this->output['offset']))
return $this->output['offset'];

else
return false;
}

public function OutputLimit()
{
if(!empty($this->output['limit']))
return $this->output['limit'];

else
return false;
}

public function PagTrue()
{
return $this->pagtrue;
}
}
?>



$news = ssi_boardNewse(95, 100, null, 300,'array');
Bölüm id = 95, kaç konu gözükücek= 100 , kaçıncı konudan başlıyacak = null,konu limiti = 300

$pagination = new Breeze_Pagination($news, $page, '', '', 5, 5); 
bir sayfada kaç ileti gözükücek = 5, kaç adet sayfa sayısı gözükücek = 5 sayfa sayısından sonra diğer sayıları <<  <1 2 3 4 5>  >> sekmesine atıyacak.


Teşekkürler snrj





a11

Demo olarak şunu verebiliriz sanırım ; http://www.mavice.net/moda.php
Elinize sağlık ;)

cee山

Quote from: Mavice on March 27, 2014, 03:34:18 PM
Demo olarak şunu verebiliriz sanırım ; http://www.mavice.net/moda.php
Elinize sağlık ;)
Bende tam onu ekliyecektim.Teşekkürler. :)

Snrj

Quote from: Hizmetci on March 28, 2014, 09:26:47 AM
Quote from: Mavice on March 27, 2014, 03:34:18 PM
Demo olarak şunu verebiliriz sanırım ; http://www.mavice.net/moda.php
Elinize sağlık ;)
Bende tam onu ekliyecektim.Teşekkürler. :)
elinize sğlık güzel olmuş :D

Advertisement: