From 6dcd6525a42dcc09fe498e61e1956e5b33aa70af Mon Sep 17 00:00:00 2001 From: Davi Alexandre Date: Fri, 1 Apr 2011 00:20:13 -0300 Subject: [PATCH] Fixing Markdown formatting for code blocks --- README.md | 97 ++++++++++++++++++++++++------------------------------- 1 file changed, 43 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index ba5fc2d..fb89c0d 100644 --- a/README.md +++ b/README.md @@ -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] - -
-

Autor: author; ?>

-

text; ?>

-
- -~~~ + +
+

Autor: author; ?>

+

text; ?>

+
+ This is how the complete view file will look like: -~~~ -[php] -
- -
-

Autor: author; ?>

-

text; ?>

-
- -
-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, -)); ?> -~~~ +
+ +
+

Autor: author; ?>

+

text; ?>

+
+ +
+ 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: