First meeting with Pagination

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
User avatar
korpirkor
Forum Members
Forum Members
Posts: 100
Joined: Sun Oct 28, 2007 1:15 pm

First meeting with Pagination

Post by korpirkor »

I was looking for pagination plugin as simple as Joomla one... I didn't find it so I wrote it by myself :-P

It will produce something like this:
(second part of content)
   >>

1. Add User Tag called stronicowanie (pagination in polish)

Code: Select all

function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}

$content = $params['content'];
$strona = isset($params['page']) ? (int)$params['page'] : '1';

$content_ex = explode('[~~~~~~~~~~~~PAGE~~~~~~~~~~~~]',$content);
$ileStron = count($content_ex);

if ($strona < 1)
	$strona = 1;
elseif ( $strona > $ileStron )
	$strona = $ileStron;

echo $content_ex[$strona-1];

if($ileStron > 1)
{
echo '<br /> <div class="strony">';

$x = parse_url(  curPageURL() ) ;
parse_str($x['query'], $output );
$url = 'index.php?' . http_build_query($output);

if ($strona > 1)
{
	$output['stronicowanie'] = 1;
	$url = 'index.php?' . http_build_query($output);
	echo '<a href="'. $url .'"><<</a>   ';
	
	$output['stronicowanie'] = $strona-1;
	$url = 'index.php?' . http_build_query($output);
	echo '<a href="'. $url .'"><</a>   ';
}

for ($i = 1; $i <= $ileStron; $i++)
{
	if ($i == $strona)
	{
		echo ' <strong>['.$i.']</strong> ';
	}
	else
	{
		$output['stronicowanie'] = $i;
		$url = 'index.php?' . http_build_query($output);
		echo '<a href="'. $url .'">'.$i.'</a>';
	}
	if ($i != $ileStron)
		echo ' - ';
}

if ($strona < $ileStron)
{
	$output['stronicowanie'] = $strona+1;
	$url = 'index.php?' . http_build_query($output);
	echo '   <a href="'. $url .'">></a>';

	$output['stronicowanie'] = $ileStron;
	$url = 'index.php?' . http_build_query($output);
	echo '   <a href="'. $url .'">>></a>';
}
echo '</div>';
}
2. In TinyMCE WYSIWYG Module, tab Advanced, field Custom dropdown add this:

Code: Select all

---|---
Insert break line|[~~~~~~~~~~~~PAGE~~~~~~~~~~~~]
3. Now, edit every {content} tag in page templates to this:

Code: Select all

{capture name="content"}{content}{/capture}
{stronicowanie content=$smarty.capture.content page=$smarty.get.stronicowanie}
That's all ;-) I hope, you will know how to use it.


You should remember, that [~~~~~~~~~~~~PAGE~~~~~~~~~~~~] should not be surrounded by any other tags !!!

for example:

Code: Select all

<p>[~~~~~~~~~~~~PAGE~~~~~~~~~~~~]</p>
First page will end by
And next one will begin by
Last edited by korpirkor on Wed Apr 21, 2010 2:53 pm, edited 1 time in total.
[url=http://www.polishwebdesign.pl/]Polish WebDesign Cezary Nowak
Projektowanie stron WWW[/ur]
Post Reply

Return to “Tips and Tricks”