[PHP] splitting content into pages
thanks to the poster on the substr page i made a modification to it so it now splits the content into pages lemme know anyone if this is useful usage: page_content($content,15,$_GET['page']); function page_content($content,$limit,$page) { $array = explode(\r\n, $content); $maxline = count($array); if ($maxline $limit) { $max = $maxline - 1; $page ? $page = $page : $page = 1; $page ? $next = $limit * ($page - 1) + 1 : $next = 1; $s=$next+$limit; for ($i=$next; $i$s; $i++) { if ($array[$i]!=) $formatted_content .= $array[$i].\n\n; //$dtrow = explode(|, $array[$i]); //$row = $dtrow[0]; //$formatted_content .= $row.\n; } $p = 1; $u = ceil($max/$limit); for ($t=1; $t$u; $t++) { $t == $page ? $formatted_content .= b$t/bnbsp; : $formatted_content .= a href=\.$_SERVER['PHP_SELF'].?.url ('page', page=$t).\$t/anbsp; ; $p=$p+$limit; } return $formatted_content; } return $content; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] splitting content into pages
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] on Wednesday, July 30, 2003 9:33 PM said: your example doesnt work Then fix it, don't complain to him. He spent his own time (either work time or personal time) to write it for you. Do you expect him to fully test it before he sends it? and the whole purpose of this is because the background image wraps if there is too much text Yes we know. Maybe you should consider changing this aspect and making things easy on yourself since this project seems little too difficult for you at this point. i'm also trying to figure out of leaving it this way and add a few page breaks at the certain length so the text doesnt go over the dark edge as u cant see it Umm.. I don't understand what you're trying to say here. any ideas ? Yes. You already have the logic information that's required to do this so now you just need to write the code which I nor anyone else are going to do for you. Another solution would be to abandon the idea of a fixed size background. Try to make it variable instead. Chris. p.s. SPACES BEFORE PUNCTUATION IS NOT COOL, IT'S WRONG. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] splitting content into pages
Another solution would be to abandon the idea of a fixed size background. Try to make it variable instead. althought not the most cross browser effective, you could also try some css to fix the background... style=background-repeat=none should do the job. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] splitting content into pages
skate mailto:[EMAIL PROTECTED] on Thursday, July 31, 2003 9:44 AM said: althought not the most cross browser effective, you could also try some css to fix the background... style=background-repeat=none should do the job. The problem is not fixing the background in place. The problem is determining when a new page is needed based on the amount of content and when it would flow over the background graphic. Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] splitting content into pages
hi there , i have an issue trying to split content into pages , we have a popup with content and a background image with a set height , when there is more content the background repeats , theoretically i'd want to split the content into pages after a given length or line length or where it meets the background image height how can i do this ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] splitting content into pages
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] on Wednesday, July 30, 2003 6:35 PM said: hi there , i have an issue trying to split content into pages , we have a popup with content and a background image with a set height , when there is more content the background repeats , theoretically i'd want to split the content into pages after a given length or line length or where it meets the background image height how can i do this ? This can be easy. 1. Make sure the content does not adjust itself based on the size of the browser window. That is to say that the space that contains the content should be a fixed width. 2. Then you need to calculate how many words you can legitimately fit into this fixed space without going over. If you 150 words will fit in the space but go right up to the very edge and are almost spilling into a new page you should pull the number of words back to 120 or something to try and make sure that the text will not spill over. You can be more precise if you use a fixed width font like Courier New. If you use a variable width font (not sure if that is the technical term) you'll have to do a little more guessing because 10 i's are not the same width as 10 w's. hth, chris. p.s. There is no space before a comma! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] splitting content into pages
ok let me explain , its straight up text content from the database , say its scrolls for ages , i need to split it into pages , so i get the length of the string up to the last paragraph which fits i need to split it there any idea ? [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] on Wednesday, July 30, 2003 6:35 PM said: hi there , i have an issue trying to split content into pages , we have a popup with content and a background image with a set height , when there is more content the background repeats , theoretically i'd want to split the content into pages after a given length or line length or where it meets the background image height how can i do this ? This can be easy. 1. Make sure the content does not adjust itself based on the size of the browser window. That is to say that the space that contains the content should be a fixed width. 2. Then you need to calculate how many words you can legitimately fit into this fixed space without going over. If you 150 words will fit in the space but go right up to the very edge and are almost spilling into a new page you should pull the number of words back to 120 or something to try and make sure that the text will not spill over. You can be more precise if you use a fixed width font like Courier New. If you use a variable width font (not sure if that is the technical term) you'll have to do a little more guessing because 10 i's are not the same width as 10 w's. hth, chris. p.s. There is no space before a comma! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] splitting content into pages
maybe somehow with a substr function that gets the position of the last paragraph ?? ok let me explain , its straight up text content from the database , say its scrolls for ages , i need to split it into pages , so i get the length of the string up to the last paragraph which fits i need to split it there any idea ? [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] on Wednesday, July 30, 2003 6:35 PM said: hi there , i have an issue trying to split content into pages , we have a popup with content and a background image with a set height , when there is more content the background repeats , theoretically i'd want to split the content into pages after a given length or line length or where it meets the background image height how can i do this ? This can be easy. 1. Make sure the content does not adjust itself based on the size of the browser window. That is to say that the space that contains the content should be a fixed width. 2. Then you need to calculate how many words you can legitimately fit into this fixed space without going over. If you 150 words will fit in the space but go right up to the very edge and are almost spilling into a new page you should pull the number of words back to 120 or something to try and make sure that the text will not spill over. You can be more precise if you use a fixed width font like Courier New. If you use a variable width font (not sure if that is the technical term) you'll have to do a little more guessing because 10 i's are not the same width as 10 w's. hth, chris. p.s. There is no space before a comma! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] splitting content into pages
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] on Wednesday, July 30, 2003 7:04 PM said: ok let me explain , its straight up text content from the database , say its scrolls for ages , i need to split it into pages , so i get the length of the string up to the last paragraph which fits i need to split it there any idea ? The primitive, basic way to do this is: 1. grab the entire document and explode it on 2. determine how many pages there are 3. display the first page (120 words) 4. on the next page start back at 1 except when you get to #3 go to #5 instead. 5. display the next 120 words by multiplying the page number by 120 and continuing until pageNumber*120+120. For example, you're on page 2, and your showing 120 words per page. That would be 2*120+120. Words shown on page 2 are 240 through 360. 6. continue until all pages are done. Make sense? Chris. p.s. No spaces come before punctuation in English. Sorry to dissapoint you again. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] splitting content into pages
Is there a reason this can't be solved with a CSS background-repeat: repeat-y; ? Or is download time of individual pages an issue? This is really a client-side issue. The math is going to vary depending on each user's settings- which font is used, the size of the font, random browser stupidity, etc. Even if you try to specify such things, you'll have issues. If you try to use a specific font, what if the user doesn't have it? What if they have vision problems and have ordered fonts to be larger than usual? IMHO it would be better to just use CSS and put everything on the same page On Wednesday 30 July 2003 07:06 pm, [EMAIL PROTECTED] wrote: maybe somehow with a substr function that gets the position of the last paragraph ?? ok let me explain , its straight up text content from the database , say its scrolls for ages , i need to split it into pages , so i get the length of the string up to the last paragraph which fits i need to split it there any idea ? [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] on Wednesday, July 30, 2003 6:35 PM said: hi there , i have an issue trying to split content into pages , we have a popup with content and a background image with a set height , when there is more content the background repeats , theoretically i'd want to split the content into pages after a given length or line length or where it meets the background image height how can i do this ? This can be easy. 1. Make sure the content does not adjust itself based on the size of the browser window. That is to say that the space that contains the content should be a fixed width. 2. Then you need to calculate how many words you can legitimately fit into this fixed space without going over. If you 150 words will fit in the space but go right up to the very edge and are almost spilling into a new page you should pull the number of words back to 120 or something to try and make sure that the text will not spill over. You can be more precise if you use a fixed width font like Courier New. If you use a variable width font (not sure if that is the technical term) you'll have to do a little more guessing because 10 i's are not the same width as 10 w's. hth, chris. p.s. There is no space before a comma! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Status: 0 Content-type: text/html [cgi] To be true to the mythical conception of a God is to be false to the interests of mankind. -E. Haldeman-Julius -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] splitting content into pages
Evan Nemerson mailto:[EMAIL PROTECTED] on Wednesday, July 30, 2003 7:17 PM said: Is there a reason this can't be solved with a CSS background-repeat: repeat-y; ? Or is download time of individual pages an issue? That can look funny of course if the picture doesn't tile well. The math is going to vary depending on each user's settings- which font is used, the size of the font, random browser stupidity, etc. Even if you try to specify such things, you'll have issues. Too true. If you try to use a specific font, what if the user doesn't have it? What if they have vision problems and have ordered fonts to be larger than usual? Right again. IMHO it would be better to just use CSS and put everything on the same page But the problem with this is that people don't like really long pages. It makes them (I've read this in a few places and I know I feel this way) feel like it's going to take forever to read a really long article instead of maybe five screen length pages. I think pages are a good idea for long articles but I agree that it's a sticky situation to try and accomate everyone, especially with the original posters requirements (wants more than one page because of the background). Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] splitting content into pages
this isnt a client side issue it'll defeat the purpose if i dont repeat the background image and then let the text flow over it , its supposed to look like a notepage for a blogger Is there a reason this can't be solved with a CSS background-repeat: repeat-y; ? Or is download time of individual pages an issue? This is really a client-side issue. The math is going to vary depending on each user's settings- which font is used, the size of the font, random browser stupidity, etc. Even if you try to specify such things, you'll have issues. If you try to use a specific font, what if the user doesn't have it? What if they have vision problems and have ordered fonts to be larger than usual? IMHO it would be better to just use CSS and put everything on the same page On Wednesday 30 July 2003 07:06 pm, [EMAIL PROTECTED] wrote: maybe somehow with a substr function that gets the position of the last paragraph ?? ok let me explain , its straight up text content from the database , say its scrolls for ages , i need to split it into pages , so i get the length of the string up to the last paragraph which fits i need to split it there any idea ? [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] on Wednesday, July 30, 2003 6:35 PM said: hi there , i have an issue trying to split content into pages , we have a popup with content and a background image with a set height , when there is more content the background repeats , theoretically i'd want to split the content into pages after a given length or line length or where it meets the background image height how can i do this ? This can be easy. 1. Make sure the content does not adjust itself based on the size of the browser window. That is to say that the space that contains the content should be a fixed width. 2. Then you need to calculate how many words you can legitimately fit into this fixed space without going over. If you 150 words will fit in the space but go right up to the very edge and are almost spilling into a new page you should pull the number of words back to 120 or something to try and make sure that the text will not spill over. You can be more precise if you use a fixed width font like Courier New. If you use a variable width font (not sure if that is the technical term) you'll have to do a little more guessing because 10 i's are not the same width as 10 w's. hth, chris. p.s. There is no space before a comma! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Status: 0 Content-type: text/html [cgi] To be true to the mythical conception of a God is to be false to the interests of mankind. -E. Haldeman-Julius -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] splitting content into pages
Excellent point. A compromise, then? How about using the background-repeat: repeat-y; and not trying to do any math. Just decide how long the content should be, and wrap the page at the next sentence. That way, you make the end users happy, but don't risk an ugly page. For 150 characters, (untested) style type=text/css background-repeat: repeat-y; /style /head body p ?php $x = 150; while ( $c != '.' ) $c = substr($str, $x, 1); echo substr($str, 0, $x); echo /ppa href=\popup.php?startchar=$x\Next page/a/p; ? /body On Wednesday 30 July 2003 07:44 pm, Chris W. Parker wrote: Evan Nemerson mailto:[EMAIL PROTECTED] on Wednesday, July 30, 2003 7:17 PM said: Is there a reason this can't be solved with a CSS background-repeat: repeat-y; ? Or is download time of individual pages an issue? That can look funny of course if the picture doesn't tile well. The math is going to vary depending on each user's settings- which font is used, the size of the font, random browser stupidity, etc. Even if you try to specify such things, you'll have issues. Too true. If you try to use a specific font, what if the user doesn't have it? What if they have vision problems and have ordered fonts to be larger than usual? Right again. IMHO it would be better to just use CSS and put everything on the same page But the problem with this is that people don't like really long pages. It makes them (I've read this in a few places and I know I feel this way) feel like it's going to take forever to read a really long article instead of maybe five screen length pages. I think pages are a good idea for long articles but I agree that it's a sticky situation to try and accomate everyone, especially with the original posters requirements (wants more than one page because of the background). Chris. -- He died in AD 33. Get over it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] splitting content into pages
ok i have an idea , i have a solution which may work i dont know just yet , ok say the strlen of the entire content is 1675 , the strlen of the content up to the last paragraph is 1300 , how can i substr this to get the next block of text from 1300 and also increment if there is more pages ?? Evan Nemerson mailto:[EMAIL PROTECTED] on Wednesday, July 30, 2003 7:17 PM said: Is there a reason this can't be solved with a CSS background-repeat: repeat-y; ? Or is download time of individual pages an issue? That can look funny of course if the picture doesn't tile well. The math is going to vary depending on each user's settings- which font is used, the size of the font, random browser stupidity, etc. Even if you try to specify such things, you'll have issues. Too true. If you try to use a specific font, what if the user doesn't have it? What if they have vision problems and have ordered fonts to be larger than usual? Right again. IMHO it would be better to just use CSS and put everything on the same page But the problem with this is that people don't like really long pages. It makes them (I've read this in a few places and I know I feel this way) feel like it's going to take forever to read a really long article instead of maybe five screen length pages. I think pages are a good idea for long articles but I agree that it's a sticky situation to try and accomate everyone, especially with the original posters requirements (wants more than one page because of the background). Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] splitting content into pages
your example doesnt work , and the whole purpose of this is because the background image wraps if there is too much text , i'm also trying to figure out of leaving it this way and add a few page breaks at the certain length so the text doesnt go over the dark edge as u cant see it any ideas ? Excellent point. A compromise, then? How about using the background-repeat: repeat-y; and not trying to do any math. Just decide how long the content should be, and wrap the page at the next sentence. That way, you make the end users happy, but don't risk an ugly page. For 150 characters, (untested) style type=text/css background-repeat: repeat-y; /style /head body p ?php $x = 150; while ( $c != '.' ) $c = substr($str, $x, 1); echo substr($str, 0, $x); echo /ppa href=\popup.php?startchar=$x\Next page/a/p; ? /body On Wednesday 30 July 2003 07:44 pm, Chris W. Parker wrote: Evan Nemerson mailto:[EMAIL PROTECTED] on Wednesday, July 30, 2003 7:17 PM said: Is there a reason this can't be solved with a CSS background-repeat: repeat-y; ? Or is download time of individual pages an issue? That can look funny of course if the picture doesn't tile well. The math is going to vary depending on each user's settings- which font is used, the size of the font, random browser stupidity, etc. Even if you try to specify such things, you'll have issues. Too true. If you try to use a specific font, what if the user doesn't have it? What if they have vision problems and have ordered fonts to be larger than usual? Right again. IMHO it would be better to just use CSS and put everything on the same page But the problem with this is that people don't like really long pages. It makes them (I've read this in a few places and I know I feel this way) feel like it's going to take forever to read a really long article instead of maybe five screen length pages. I think pages are a good idea for long articles but I agree that it's a sticky situation to try and accomate everyone, especially with the original posters requirements (wants more than one page because of the background). Chris. -- He died in AD 33. Get over it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php