Prev - Next links for page break in Full Story! [HowTo]

What do you think about the script.

Prev - Next links for page break in Full Story! [HowTo]

Postby DarkSlim » Mon Nov 02, 2009 5:21 pm

There was a question (from DistantJ) about making Prev and Next links
in full story (when dividing the post to pages using 'pagebreak' or 'nextpage' as it is also called)
Here is a way to do it:

Open inc/show.news.php

Find (it may look a bit different since I modified it (as I wrote here here) :
Code: Select all
if ($page_count > 1){
            $output = str_replace('[page-link]', '', $output);
            $output = str_replace('[/page-link]', '', $output);

            for ($i = 1; $i < $page_count + 1; $i++){
               if (($page and $page == $i) or ($allow_full_story and !$page and $i == 1)){
                  $pages .= ' <b>'.$i.'</b> ';
               } else {
                  $pages .= ' <a href="'.$PHP_SELF.'?id='.$row[id].'&page='.$i.'">'.$i.'</a> ';
               }
            }


Under Add:
Code: Select all
                                        //DarkSlim's code for next/prev links in full story
                                              if(isset($page)){
                                                if ($page != $page_count){
                                                  $nextc = $page + 1;
                                                 $nextpage .= '<a href="'.$PHP_SELF.'?id='.$row[id].'&page='.$nextc.'">NEXT</a>';
                                                }
                                                  if ($page != '1'){
                                                 $prevc = $page - 1;
                                                  $prevpage .= '<a href="'.$PHP_SELF.'?id='.$row[id].'&page='.$prevc.'">PREV</a>';
                                                }
                                              } else {
                                                  $nextc = '2';
                                                 $nextpage .= '<a href="'.$PHP_SELF.'?id='.$row[id].'&page='.$nextc.'">NEXT</a>';
                                                }


* You can change the words NEXT and PREV for whatever you like
You can replace them with image buttons too (html syntax)


Then, Find:
Code: Select all
      $output = str_replace('{pages}', $pages, $output);


After Add:
Code: Select all
        $output = str_replace('{nextpages}', $nextpage, $output);
        $output = str_replace('{prevpages}', $prevpage, $output);


That's it! edit your template and instead of just {pages} use the new tags!
Like this for example:
[page-link]{prevpages}({pages}){nextpages}[/page-link]


Use it as you like, hope this helps. :)

Edit: I fixed a bug in the code when you first enter the post and the $page variable is not yet set
Now it works perfectly (if you have any other questions or suggestions i'de love to hear) :)

DarkSlim
Last edited by DarkSlim on Tue Nov 10, 2009 4:53 pm, edited 1 time in total.
User avatar
DarkSlim
 
Posts: 298
Joined: Thu Aug 06, 2009 4:18 pm
Location: IL

Postby DarkSlim » Tue Nov 10, 2009 4:52 pm

Any moderator can move this thread to "Suggestions" ? (mistakenly opened it here) :o ^^'
User avatar
DarkSlim
 
Posts: 298
Joined: Thu Aug 06, 2009 4:18 pm
Location: IL


Return to General feedback



Who is online

Users browsing this forum: No registered users and 0 guests

cron