Jump to content

help with Pagination


drilonb
 Share

Recommended Posts

I like to know how to make page Pagination i have category  example name BMW  and in this category i have listing for BMW and i like to show it in every 10 listing 1 page , 2 page etc..

i try to use it

$results = $pages->find("limit=n, start=0");
echo $results->render();

and

$results = $pages->find("id>1, limit=10, sort=title");
echo $results->render(); 

But is calling all pages in numbers and links i try and from http://processwire.com/api/modules/markup-pager-nav/  but maybe i am doing something wrong for example u have in http://processwire.com/skyscrapers/cities/columbus/  u have 2 pages i like to make like this to show only columbus listings 2 methods one with next numbers and previous  and one method just next and previous u have one i this post  http://processwire.com/talk/index.php/topic,28.0.html

thanks

Link to comment
Share on other sites

If you want PW to do the pagination for you, you don't ever need to specify a "start=0" in your selector. PW will take care of making sure it starts at the right place, as long as you have page numbers turned on for your template (Admin > Setup > Templates > Advanced > Page Numbers).

The "limit=n" implies that you substitute a number for "n", i.e. "limit=10".

In the examples you listed, it looks like you are pulling from all the pages in the site? I'm guessing you want to pull from a more specific set of pages, like this?

<?php
$results = $pages->find("parent=/categories/bmw/, limit=10, sort=title"); 
echo $results->render(); 

or another way of saying the same thing:

<?php
$results = $pages->get("/categories/bmw/")->children("limit=10, sort=title"); 
echo $results->render(); 

One other thing I want to note is that $results->render() is provided by a plugin module. Make sure you have these modules installed under Admin > Modules > Markup > (you may need to click the 'install' button to activate them)

  • MarkupPageArray: PageArray Markup
  • MarkupPagerNav: Pager (Pagination) Navigation

That render() method is just provided for convenience, and it doesn't do anything other than output a list of pages linked by title. Chances are you'll want to generate your own nav and then use the $results->renderPager() method at the bottom to output the pagination navigation.

Link to comment
Share on other sites

You are GREAT i use this

<?php
$results = $pages->find("parent=/shtepi/shtepi-ne-shitje/, limit=5, sort=title");
echo $results->renderPager(); 

here if some one like to have a Simple CSS for Pagination


div class="pagination">

<?php
$results = $pages->find("parent=/shtepi/shtepi-ne-shitje/, limit=5, sort=title");
echo $results->renderPager(); 
?>
</div>

CSS

/*---------------------pagination-----------------------------*/

div.pagination {
   padding:5px;
   margin:5px;
   text-align:center;
   float:left;
   font-size:10px;
}

div.pagination a {
   padding: 2px 5px 2px 5px;
   margin-right: 2px;
   border: 1px solid #ddd;
   
   text-decoration: none;
   color: #d8325d;
}
div.pagination a:hover, div.pagination a:active {
   border:1px solid #ddd;
   color: #fff;
   background-color: #d8325d;
}
div.pagination span.current {
   padding: 2px 5px 2px 5px;
   margin-right: 2px;
   border: 1px solid #ddd;
   font-weight: bold;
   background-color: #d8325d;
   color: #FFF;
}
div.pagination span.disabled {
   padding: 2px 5px 2px 5px;
   margin-right: 2px;
   border: 1px solid #ddd;
   color: #ccc;
}

Now everything is coming beautiful with PW,

Thanks.

Link to comment
Share on other sites

Looking good! My only question is where you rendering the $results? I just see the $results->renderPager(), and that only outputs the pagination navigation. Do you have some code after the "find()" and before the "echo" that renders the results?

Link to comment
Share on other sites

yes of course this is a code with table sort latest product in home sales shows 5 for each page,

<?php
		$children = $pages->get("/shtepi/shtepi-ne-shitje/")->children("sort=-created, images>0, limit=5");
		foreach($children as $prishtina) {
		$image = $prishtina->images->first(); 
		$thumb = $image->size(190, 98); 	
		echo "
		<tr class='color1' onmouseout='style.backgroundColor='#F3F5F6'' onclick='document.location.href='#.html'' onmouseover='this.style.cursor='pointer'; style.backgroundColor='#ffffff'' title='Vezi detaliile anuntului' >
			<td><a href='{$prishtina->url}'><img src='{$thumb->url}' class='img_left' alt='' title='' border='0'/></a></td>
               <td><a href='{$prishtina->url}'>{$prishtina->qmimi} $ </td>
               <td><a href='{$prishtina->url}'>{$prishtina->qyteti}</td>
               <td><a href='{$prishtina->url}'>{$prishtina->prodhimi}</td>
		</tr>
			";
			};

And this is code in my template,

works perfect

<div class="column4">
        
		<div class="title" style="float:left;">
			<div style="float:left;">Shtepi ne shitje</div>
			</div> 
			<table style="clear:both; width:695px; margin-top:10px;" cellpadding="0" cellspacing="0" border="0">
            
			<tr>
                <th><center>Foto</center></th>
                <th>Qmimi</th>
			<th>Vendi</th> 
                <th>Viti i prodhimit</th>        
			</tr>    
		<?php
		$children = $pages->get("/shtepi/shtepi-ne-shitje/")->children("sort=-created, images>0, limit=5");
		foreach($children as $prishtina) {
		$image = $prishtina->images->first(); 
		$thumb = $image->size(190, 98); 	
		echo "
		<tr class='color1' onmouseout='style.backgroundColor='#F3F5F6'' onclick='document.location.href='#.html'' onmouseover='this.style.cursor='pointer'; style.backgroundColor='#ffffff'' title='Vezi detaliile anuntului' >
			<td><a href='{$prishtina->url}'><img src='{$thumb->url}' class='img_left' alt='' title='' border='0'/></a></td>
                <td><a href='{$prishtina->url}'>{$prishtina->qmimi} $ </td>
                <td><a href='{$prishtina->url}'>{$prishtina->qyteti}</td>
                <td><a href='{$prishtina->url}'>{$prishtina->prodhimi}</td>
		</tr>
			";
			};
		?>
            </table>
            <div class="pagination">
		<?php
		$results = $pages->find("parent=/shtepi/shtepi-ne-shitje/, limit=5, sort=title");
		echo $results->renderPager(); 
		?>
            </div>

        </div><!-- end of Home Sales Table list four -->
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...