How to represents post content in multiple pages?

I know I can use CPagination and CLinkPager to represents list view in multiple pages if the list is too long. But how should I do if I want to implement it with yii in the post content (show) view if the content is too long?

You can substr content by number of symbols and add get parameter ‘showall’ to disable substr.

With this problem, I would aim for a somewhat customized solution. Like introducing something like a <pagebreak> tag or other symbol you scan for in the show Action and then split the post content accordingly.

For the splitting you could use something like:

$postPagedContent = explode('<pagebreak>', $post->content);

After that you could use the $postPagedContent array to fill CPagination Object.

Maybe this helps.

Best regards, Steffen

Thank you for your reply. But I can’t understand what is the meaning of “use the $postPagedContent array to fill CPagination”, I think fist step is “$pages=new CPagination( count($postPagedContent) );” and then…?

Thanks for your help again.

and then in view


I had tried this, but no effect, it seems that the ‘pages’ does not provide enough information to CLinkPager.

Yes you’re right. The effect here is, that CPagination has a default setting for displaying 10 items per page. So, since you want to display one item per page here (here one page of the post content) you have to set the pageSize property of your CPagination object accordingly.

So in your controller:

// ...

$pages = new CPagination(count($postPagedContent));


// ...

$this->render('templatename', array('pages'=>$pages,'postContent'=>$postPagedContent));

And in your view:

echo $postContent[$pages->getCurrentPage()];


Hope that helps,


That’t it! Thanks very much for your help! :)