Welcome Guest, Not a member yet? Register   Sign In
Dvide article for part.
#1

[eluser]jedre[/eluser]
Hello,

I have a question, how can I divide long article for smaller part (pages).
Is it easy way to resolve this problem by use CI?

Sorry for ma English Smile
#2

[eluser]schnoodles[/eluser]
You could always jsut truncate the text to a certain amount of chars.

Have a look in the Text Helper for some nifty functions.

You might also want to look into pagination to create several pages with navigation.
#3

[eluser]jedre[/eluser]
[quote author="schnoodles" date="1193372192"]You might also want to look into pagination to create several pages with navigation.[/quote]

Yea!
..but how?

In article I have: title, author, write_date, content.
Content is a lot of words. How divide it for few pages using pagination. I don't have idea.
#4

[eluser]xwero[/eluser]
using
Code:
function wordcount($str) {
return count(array_filter(explode(' ', $str)));
}
function wordlimiter($str,$start,$end){
$temp = array_filter(explode(' ', $str));
return array_slice($temp,$start,$end);
}
you could split up the article for instance in three parts
Code:
$words = wordcount($row->content);
$partwordsnr = floor($words/3);
$parts = array();
$start = 0;
$end = $partwordsnr;
for($i=0;$i<3;$i++)
{
   $parts[] = wordlimiter($row->content,$start,$end);
   $start = $partwordsnr;
   $end = $count+$partwordsnr;
}
Then in the view you could do something like
Code:
<div class="articlecontent">
&lt;?php foreach($parts as $part){ ?&gt;
<div class="articlepart">&lt;?php echo $part; ?&gt;</div>
&lt;?php } ?&gt;
</div>
It's ruff code but it might give you some idea on how you can accomplish what you want.

update : code mistake
#5

[eluser]xwero[/eluser]
The code i displayed is if the pageparts are shown and hidden using javascript that way you can easily switch between showing the whole article and the cut up version.




Theme © iAndrew 2016 - Forum software by © MyBB