Long Article Pagination

Hi Everyone,

I am new to Yii and have spent the last couple of weeks reading documentation and experimenting with the framework.

I am developing a website which will feature some long articles and am looking for an easy way to split up content that has been entered in the body of the article (ideally through a WYSIWYG extension) into separate pages. The ideal situation would be to have a pager like the built in Yii one to show at the bottom so I could move from page to page of the article with ajax.

I have searched around for either an extension or forum topic on this and was quite surprised that I couldn’t find existing discussions. Can anyone point me in the right direction on a potential elegant solution, ideally using the Yii CPagination?

Many thanks in advance for any help you can offer!

Robin

This shouldn’t be difficult.

You can use a seperator like "—" to split up the content in multiple pages.

Then, after retrieving the content, you can explode the text, so you have an array containing each page.

Then you need CArrayDataProvider:

http://www.yiiframework.com/doc/api/1.1/CArrayDataProvider

This formats the data so that Yii’s built in widgets recognize it.

After that, you can use Clistview to display the data:

http://www.yiiframework.com/doc/api/1.1/CListView

This will give you a nice customizable overview of the data with ajax pagination (and if you want; sorting, searching etc).

If this doesn’t work for you I can provide examples.

Hi Wisp,

Thanks for this really informative reply - your suggestions make perfect sense to me and I will experiment with this approach. I love the flexibility of this framework and can see more and more that it is about a bit of imagination rather than any limits!

Robin