I have got my Pager working on my Home page folder and getting this kind url: http://127.0.0.1/eripma/?articles.html?page=2
I know this is because I don't have the .htaccess configured on my local system.
Only got one strange thing. This is on my home. and i'm want to use the articles in the articles folder. But i'm also getting the articles from the other folders. When i'm on the second page (articles) everything works fine, even when you go back to page 1 you get all the articles.
But the frontpage gives a couple of content pages.
How can I change this to get this working? My code on the frontpage:
<?php use_helper('Pager');
$pager = new Pager(array(
'style' => 'classic', // other styles are available
'items_per_page' => 4, // set this to number of your choice
'total_items' => $this->childrenCount()
)); ?>
<?php
$page_article = $this->find('/articles/');
if ($page_article->childrenCount() > 0) {
$last_article = $page_article->children(array('limit'=>1, 'order'=>'page.created_on DESC'));
//$last_articles = $this->children(array('limit'=>4, 'offset'=>($pagination->cur_page)*($pagination->per_page), 'order'=>'page.created_on DESC'));
$last_articles = $this->children(array('limit' => $pager->items_per_page, 'offset' => $pager->sql_offset, 'order'=>'page.created_on DESC'));
?>
<div class="first entry">
<h3><?php echo $last_article->link(); ?></h3>
<?php if (($more_pos = strpos($last_article->content(), '<!-- pagebreak -->')) === false ) {
// "more" trigger NOT found, so just echo content
echo $article->content();
} else {
// "more" trigger IS found, so echo only teaser and add link to whole article
echo substr($last_article->content(), 0, $more_pos);
echo '</p><p>'. $last_article->link('Read more...') .'</p>';
} ?>
</div>
<?php foreach ($last_articles as $article):?>
<div class="entry">
<h3><?php echo $article->link(); ?></h3>
<?php if (($more_pos = strpos($article->content(), '<!-- pagebreak -->')) === false ) {
// "more" trigger NOT found, so just echo content
echo $article->content();
} else {
// "more" trigger IS found, so echo only teaser and add link to whole article
echo substr($article->content(), 0, $more_pos);
echo '</p><p>'. $article->link('Read more...') .'</p>';
} ?>
</div>
<?php
endforeach;
}
?>
<?php echo $pager; ?>
Oké i've found the problem: chanced my code to this:
<?php use_helper('Pager');
$pager = new Pager(array(
'style' => 'classic', // other styles are available
'items_per_page' => 4, // set this to number of your choice
'total_items' => $this->childrenCount(),
)); ?>
<?php
$page_article = $this->find('/articles/');
if ($page_article->childrenCount() > 0) {
//$last_article = $page_article->children(array('limit'=>1, 'order'=>'page.created_on DESC'));
//$last_articles = $this->children(array('limit'=>4, 'offset'=>($pagination->cur_page)*($pagination->per_page), 'order'=>'page.created_on DESC'));
$last_articles = $page_article->children(array('limit' => $pager->items_per_page, 'offset' => $pager->sql_offset, 'order'=>'page.created_on DESC'));
?>
<!--<div class="first entry">
<h3><?php //echo $last_article->link(); ?></h3>
<?php //if (($more_pos = strpos($last_article->content(), '<!-- pagebreak -->')) === false ) {
// "more" trigger NOT found, so just echo content
// echo $article->content();
//} else {
// "more" trigger IS found, so echo only teaser and add link to whole article
//echo substr($last_article->content(), 0, $more_pos);
//echo '</p><p>'. $last_article->link('Read more...') .'</p>';
//} ?>
</div>-->
<?php foreach ($last_articles as $article):?>
<div class="entry">
<h3><?php echo $article->link(); ?></h3>
<?php if (($more_pos = strpos($article->content(), '<!-- pagebreak -->')) === false ) {
// "more" trigger NOT found, so just echo content
echo $article->content();
} else {
// "more" trigger IS found, so echo only teaser and add link to whole article
echo substr($article->content(), 0, $more_pos);
echo '</p><p>'. $article->link('Read more...') .'</p>';
} ?>
</div>
<?php
endforeach;
}
?>
<?php echo $pager; ?>
Last edited by Gix (2011-07-03 14:49)