Permalink
Browse files

Fixing Markdown formatting for code blocks

  • Loading branch information...
1 parent 3e01898 commit 6dcd6525a42dcc09fe498e61e1956e5b33aa70af @davialexandre committed Apr 1, 2011
Showing with 43 additions and 54 deletions.
  1. +43 −54 README.md
View
@@ -12,73 +12,62 @@ The YiinfiniteScroller class extends the CBasePager class, so you will use it th
On your controller you need to create the CPagination class which controls the pages handling:
-~~~
-[php]
-class PostController extends Controller
-{
- public function actionIndex()
+ class PostController extends Controller
{
- $criteria = new CDbCriteria;
- $total = Post::model()->count();
-
- $pages = new CPagination($total);
- $pages->pageSize = 20;
- $pages->applyLimit($criteria);
-
- $posts = Post::model()->findAll($criteria);
-
- $this->render('index', array(
- 'posts' => $posts,
- 'pages' => $pages,
- ));
+ public function actionIndex()
+ {
+ $criteria = new CDbCriteria;
+ $total = Post::model()->count();
+
+ $pages = new CPagination($total);
+ $pages->pageSize = 20;
+ $pages->applyLimit($criteria);
+
+ $posts = Post::model()->findAll($criteria);
+
+ $this->render('index', array(
+ 'posts' => $posts,
+ 'pages' => $pages,
+ ));
+ }
}
-}
-~~~
Now on your view you will use it as a widget, like in the following sample:
-~~~
-[php]
-$this->widget('ext.yiinfinite-scroll.YiinfiniteScroller', array(
- 'itemSelector' => 'div.post',
- 'pages' => $pages,
-));
-~~~
+ $this->widget('ext.yiinfinite-scroll.YiinfiniteScroller', array(
+ 'itemSelector' => 'div.post',
+ 'pages' => $pages,
+ ));
Note that this will only output the necessary code to the pager. **It will not render the page items**. Since YiinfiniteScroller extends CBasePager, everything works exactly the same way as if you were using the CListPager or CLinkPager. So, you're need to manually render the items.
In this example, the items are stored in the $posts variable. In our view, we can render the posts by using a simple foreach loop, like in the example bellow:
-~~~
-[php]
-<?php foreach($posts as $post): ?>
- <div class="post">
- <p>Autor: <?php echo $post->author; ?></p>
- <p><?php echo $post->text; ?></p>
- </div>
-<?php endforeach; ?>
-~~~
+ <?php foreach($posts as $post): ?>
+ <div class="post">
+ <p>Autor: <?php echo $post->author; ?></p>
+ <p><?php echo $post->text; ?></p>
+ </div>
+ <?php endforeach; ?>
This is how the complete view file will look like:
-~~~
-[php]
-<div id="posts">
-<?php foreach($posts as $post): ?>
- <div class="post">
- <p>Autor: <?php echo $post->author; ?></p>
- <p><?php echo $post->text; ?></p>
- </div>
-<?php endforeach; ?>
-</div>
-<?php $this->widget('ext.yiinfinite-scroll.YiinfiniteScroller', array(
- 'contentSelector' => '#posts',
- 'itemSelector' => 'div.post',
- 'loadingText' => 'Loading...',
- 'donetext' => 'This is the end... my only friend, the end',
- 'pages' => $pages,
-)); ?>
-~~~
+ <div id="posts">
+ <?php foreach($posts as $post): ?>
+ <div class="post">
+ <p>Autor: <?php echo $post->author; ?></p>
+ <p><?php echo $post->text; ?></p>
+ </div>
+ <?php endforeach; ?>
+ </div>
+ <?php $this->widget('ext.yiinfinite-scroll.YiinfiniteScroller', array(
+ 'contentSelector' => '#posts',
+ 'itemSelector' => 'div.post',
+ 'loadingText' => 'Loading...',
+ 'donetext' => 'This is the end... my only friend, the end',
+ 'pages' => $pages,
+ )); ?>
+
There are a few properties that can be set for YiinfiniteScroller:

0 comments on commit 6dcd652

Please sign in to comment.