Jump to content

Recommended Posts

IS there a way to place pagination markers within a text block, and have the php read them and follow them, for example:

 

[#newpage:1]Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla consequat. Pellentesque viverra turpis vel sapien. Sed consectetuer felis vel ante. Quisque egestas magna id justo. Nulla rutrum sodales ligula. Integer placerat purus sit amet libero. Pellentesque mauris. Aenean ut massa id mauris scelerisque tempor. Maecenas ipsum. Proin sodales. 
[#newpage:2]Donec pellentesque, enim sit amet nonummy volutpat, dui mauris condimentum odio, id mollis urna nulla id eros. Nulla commodo ligula sed eros. Morbi lectus mi, condimentum sit amet, volutpat volutpat, aliquam in, nulla. Vestibulum gravida. Curabitur erat nibh, dapibus vulputate, tincidunt sit amet, luctus nec, velit. Cras risus neque, lobortis at, faucibus in, varius non, nisi. Pellentesque leo risus, consectetuer ac, dictum quis, volutpat in, augue. Etiam ultricies. Etiam id purus. Nullam vel orci. Donec metus felis, rhoncus scelerisque, fermentum vitae, laoreet nec, erat. In pede elit, posuere vitae, mattis sed, viverra ut, leo. Nunc commodo ligula eget ipsum. Ut dignissim arcu nec dui. Nam in nunc nec eros porttitor venenatis. Vivamus id odio vitae felis iaculis feugiat. Ut venenatis tortor ac dui. 
[#newpage:3]Donec at justo sed arcu pharetra porttitor. Pellentesque accumsan consequat metus. Duis porttitor rhoncus massa. Proin lacinia ipsum ac nisl. Etiam condimentum malesuada est. Donec lacinia posuere ipsum. Duis eu augue vel nibh rutrum tincidunt. Nunc interdum lacus eu nibh. Aliquam neque. Sed elementum massa id elit.

 

And then have a url like this:

 

http://example.com/somepage.php?page=1

 

And it would only read from [#newpage:1] to [#newpage:2], printing out:

 

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla consequat. Pellentesque viverra turpis vel sapien. Sed consectetuer felis vel ante. Quisque egestas magna id justo. Nulla rutrum sodales ligula. Integer placerat purus sit amet libero. Pellentesque mauris. Aenean ut massa id mauris scelerisque tempor. Maecenas ipsum. Proin sodales.

 

Is this possible and if so, how would I go about doing it?

 

I have a tutorials section on my site and I don't feel like re-doing the database structure, if I could just modify the php page a little that would be a LOT easier.

 

So...anyone?

Link to comment
https://forums.phpfreaks.com/topic/64479-solved-in-text-pagination-help-please/
Share on other sites

Sweet-NUSS.  That helped.  I've finished it up to figure out how many pages there are, then to write up a list with links to other pages, except the one you are on, that one is bolded, here:

 

$snoopy->fetch("http://claninfectionist.com/misc/testing/pagetest.txt");
$text = $snoopy->results;
$numpages = preg_match_all('/\[#newpage:(\d)\]/', $text, $pages);
$numpages = max($pages[1]);
$p = $_GET['page'];
$p = (isset($p)) ? $p : 1 ;
preg_match('/\[#newpage:'.$p.'\](.*)/', $text, $b);
echo $text = isset($b[1]) ? $b[1] : 'no text to print';
echo "<br /><br />\n\n";
foreach($pages[1] as $page) {
  //echo ($page == $p) ? (($page == $numpages) ? $page : $page." | " ) : (($page == $numpages) ? $page : "<a href=\"{$_SERVER['PHP_SELF']}?page=".$page."\">".$page."</a> | " ) ;
  $pagenum = ($page == $p) ? "<b>".$page."</b>" : "<u><a href=\"{$_SERVER['PHP_SELF']}?page=".$page."\">".$page."</a></u>";
  $pagenum .= ($page != $numpages) ? " | " : '';
  echo $pagenum;
  }
?>

 

Thank you for your help.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.