1 (edited by 2008-08-14 21:39:03)

Topic: [HACK] Next/Previous Links

Name: Next/Previous Links
Author: StealthEye
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Go to the next or previous story when looking at your full story.
Instructions:

// Prev Next For Full Story
$index = array_search($active_news, $all_active_news);
$prev = explode("|", $all_active_news[$index - 1], 2);
$next = explode("|", $all_active_news[$index + 1], 2);

$next_link = 

"$PHP_SELF?subaction=showfull&id=$next[0]&archive=$archive&start_from=$start_from&ucat=$ucat&$us

er_query";
$prev_link = 

"$PHP_SELF?subaction=showfull&id=$prev[0]&archive=$archive&start_from=$start_from&ucat=$ucat&$us

er_query";

$output = str_replace("[next]", $next[0] ? "[url=]" : "", $output);
$output = str_replace("[prev]", $prev[0] ? "<a href=\"$prev_link\">" : "", $output);
$output = str_replace("[/next]", $next[0] ? "[/url]" : "", $output);
$output = str_replace("[/prev]", $prev[0] ? "</a>" : "", $output);
// End Prev Next For Full Story

add it below the 1st instance of

$output = str_replace("{cute-http-path}", $config_http_script_dir, $output);

That's around line 250 in SHOWS.INC.PHP in your INC folder.


TO INCLUDE THE NEXT/PREV LINKS IN YOUR TEMPLATE:

[next]<< Next[/next] - [prev]Previous >>[/prev]

Re: [HACK] Next/Previous Links

Update:

This is a new plugin version of the above that will work in version 168 of AJ-Fork and in pfork (plugin cutenews original).  Thanks to JuggaG and Stealtheye for this plugin.

<?php

/*
Plugin Name: Prev and Next Link Text In Full Story
Plugin URI: http://www.jubbag.com
Description: Adds a link with the next and previous news stories with their title as the Link Text. Use {prevlink} and {nextlink}. Comes with formatting: << Previous | and | Next >>. Feel free to edit it in the code of the plugin. Based on code from [url=https://cutephp.com/forum-old/index.php?showtopic=3690&hl=prev%20next&st=0]CuteNews Forum[/url] by [url=http://www.cncreneclips.com]Stealtheye[/url]
Version: 0.5
Author:    J-Dawg
Author URI:    http://www.jubbag.com
Application: CuteNews
Required Framework: 1.0.0
*/


add_filter('news-show-generic','prev_next');


function prev_next($output,$hook)
{

    global $all_active_news;
    global $active_news;
    $index = array_search($active_news, $all_active_news);
    $prev = explode("|", $all_active_news[$index - 1]);
    $next = explode("|", $all_active_news[$index + 1]);
    $next_link = "[url=$PHP_SELF?subaction=showfull&id=$next[0]&archive=$archive&start_from=$start_from&ucat=$ucat&$user_query]« $next[2][/url] | ";
    $prev_link = " | [url=$PHP_SELF?subaction=showfull&id=$prev[0]&archive=$archive&start_from=$start_from&ucat=$ucat&$user_query]$prev[2] »[/url]";
    if (!empty($next[0]))
    {
  $output = str_replace("{nextlink}", $next_link, $output);
    }
    else
    {
  $output = str_replace("{nextlink}", "", $output);
    }
    if (!empty($prev[0]))
    {
  $output = str_replace("{prevlink}", $prev_link, $output);
    }
    else
    {
  $output = str_replace("{prevlink}", "", $output);
    }
    return $output;
    
}


?>

Open a textfile, paste the above in, name it to something like next-previous-titles.php and then shove it in the plugins folder big_smile  Then all you gotta do is enable it from the "Options - Plugin Manager" section.