Help -- (Topic Extraction) all links lead to the same topic


  -----  
Author Message

HB.
Member

Fri May 25, 2007 3:02 pm   Post subject: Help -- (Topic Extraction) all links lead to the same topic
Hello,

I have installed the Topic Extraction hack to fetch the 5 most recent topics, and display them as links on my homepage. The only problem that I'm having is all the links lead to the same topic which is the most recent. Has anyone had this problem, and know how to correct this. The code I'm using is:

Code:

<?php
## Mod Title: Topic Extraction
## Version: 1.5.2

#############
## Edit Below
#############
// Where to take the topics from
// Always a number
$forum = '1';

// How many topics to show
$limit = '5';

// How to show the topics
// full or blank ('')
$show = '';

// How to display the date and time if used
// short or long
$date_time = 'long';

// How top display the topic link if usede
// topic or phpbb
$topic_link = 'phpbb';

// Comments link - how to send them to comments
// topic or reply
$comment = 'topic';

// Path to your forums directory
// Usually ./forum/ or ./phpBB/ or ./forums/
$phpbb_root_path = './phpbb/';

#############################################
## No Editing unless you know what your doing
#############################################
if ( !defined('IN_PHPBB') )
{
  define('IN_PHPBB', true);
  include($phpbb_root_path  . 'extension.inc');
  include($phpbb_root_path  . 'common.'.$phpEx);
  include($phpbb_root_path  . 'config.'.$phpEx);
}

if ($show == '' || $show == 'full')
{
   // Select the topic information from the correct forum and set it to $grab_topics
   $grab_topics = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}' AND `topic_moved_id` = '0' ORDER BY `topic_id` DESC LIMIT {$limit}");
}

else if ($show == 'topic')
{
   $grab_topics = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$_GET['t']}' ORDER BY `topic_id` DESC");
}
   
// Grab the information using an array and set it to $echo_topic
while ($echo_topic = $db->sql_fetchrow($grab_topics))
{
   // Select the post information from the correct forum and set it to $grab_posts
   $grab_posts = $db->sql_query("SELECT * FROM `{$table_prefix}posts` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$echo_topic['topic_id']}' LIMIT 1");
   
   // Grab the information using an array and set it to $echo_post
   while ($echo_post = $db->sql_fetchrow($grab_posts))
   {
      // Now get the post_text using the post_id were looking at and sort it info $grab_posts_text
      $grab_posts_text = $db->sql_query("SELECT * FROM `{$table_prefix}posts_text` WHERE `post_id` = '{$echo_post['post_id']}'");
     
      // Grab the information using an array and set it to $echo_text
      while($echo_text = $db->sql_fetchrow($grab_posts_text))
      {
         // Find the user the posted
         $find_user = $db->sql_query("SELECT * FROM `{$table_prefix}users` WHERE `user_id` = '{$echo_post['poster_id']}'");
         
         // Sort this users info into array for the post
         while ($echo_user = $db->sql_fetchrow($find_user))
         {
               
            // Get rid of all those annoying characters from bbcode
            $echo_text = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $echo_text);   
           
            // BBCode
            $echo_text = str_replace("[b]","<strong>",$echo_text);
            $echo_text = str_replace("[/b]","</strong>",$echo_text);
               
            $echo_text = str_replace("[i]","<em>",$echo_text);
            $echo_text = str_replace("[/i]","</em>",$echo_text);
               
            $echo_text = str_replace("[u]","<u>",$echo_text);
            $echo_text = str_replace("[/u]","</u>",$echo_text);
               
            $echo_text = preg_replace('/\[quote=(.*)\](.*)\[\/quote\]/Usi','<div style=\"padding: 7px\">$2</div>',$echo_text);
           
            $echo_text = str_replace("[quote]","<strong>Quote</strong><em>",$echo_text);
            $echo_text = str_replace("[/quote]","</em>",$echo_text);
               
            $echo_text = str_replace("[code]","<strong>Code</strong><em>",$echo_text);
            $echo_text = str_replace("[/code]","</em>",$echo_text);
               
            $echo_text = preg_replace('/\[list\](.*)\[\/list\]/si',"<div style=\"padding: 7px\">$1</div>",$echo_text);
            $echo_text = preg_replace('/\[list=(.*)\](.*)\[\/list\]/si',"<div style=\"padding: 7px\">$1</div>",$echo_text);
               
            $echo_text = str_replace("[img]","<img src=\"",$echo_text);
            $echo_text = str_replace("[/img]","\" alt=\"image\" />",$echo_text);
               
            $echo_text = preg_replace('/\[url\](.*)\[\/url\]/Usi','<a href="$1">$1</a>',$echo_text);
            $echo_text = preg_replace('/\[url=(.*)\](.*)\[\/url\]/Usi','<a href="$1">$2</a>',$echo_text);
           
            $echo_text = preg_replace('/\[color=(.*)\](.*)\[\/color\]/Usi','<span style="{color:$1}">$2</span>',$echo_text);
            $echo_text = preg_replace('/\[size=(.*)\](.*)\[\/size\]/Usi','<span style="{font-size:$1pt}">$2</span>',$echo_text);
               
            $echo_text = str_replace("\n", "\n<br />\n", $echo_text);
               
            // Way to display date and time
            // long
            if($date_time == "long")
            {
               $echo_topic['topic_time'] = strftime("%A %e %B %H:%M",$echo_topic['topic_time']);
            }
               
            // short
            if ($date_time == "short")
            {
               $echo_topic['topic_time'] = strftime("%a %e %b %H:%M",$echo_topic['topic_time']);
            }
               
            // Way to display comment link
            // Go right to the topic
            if ($comment == 'topic')
            {
               $comment_link = "{$phpbb_root_path}viewtopic.php?t={$echo_topic['topic_id']}";
            }
           
            // Go right to the reply box
            if ($comment == 'reply')
            {
               $comment_link = "{$phpbb_root_path}posting.php?mode=reply&t={$echo_topic['topic_id']}";
            }
           
            // Topic link types
            // This link goes to the topic display
            if ($topic_link == 'topic')
            {
               $topic_link = "?show1=topic&t={$echo_topic['topic_id']}";
            }
           
            // This link goes to the actual phpbb topic
            if ($topic_link == 'phpbb')
            {
               $topic_link = "{$phpbb_root_path}viewtopic.php?t={$echo_topic['topic_id']}";
            }
           
            ##################################
            ## Edit for look and feel of topic
            ##################################
            // Display just the title
           
            if ($show != 'full' && !isset($_GET['show1']))
            {
               echo "<a href='{$topic_link}'>{$echo_text['post_subject']}</a><br />";
            }
           
            // Display many topics - for news, shoutbox etc
            else if ($show == 'full')
            {
               echo "
               <strong>{$echo_text['post_subject']}</strong> by <strong>{$echo_user['username']}</strong> at <strong>{$echo_topic['topic_time']}</strong>
               <br />
               <br />
               {$echo_text['post_text']}
               <br />
               <br />
               <a href=\"{$comment_link}\">Comments {$echo_topic['topic_replies']}</a>
               <hr size=\"1\">
               ";
            }
           
            // Display the topic for when used with the one above, click link and go here
            if ($_GET['show1'] == 'topic')
            {
               echo "
               <strong>{$echo_text['post_subject']}</strong> by <strong>{$echo_user['username']}</strong> at <strong>{$echo_topic['topic_time']}</strong>
               <br />
               <br />
               {$echo_text['post_text']}
               <br />
               <br />
               <a href=\"{$comment_link}\">Comments {$echo_topic['topic_replies']}</a>
               <hr size=\"1\">
               ";
            }
         }
      }
   }   
}
?>
 

Thoul
Administrator

Fri May 25, 2007 6:25 pm   Post subject: Re: Help -- (Topic Extraction) all links lead to the same to
There are two different variables that are sharing a name. One is used for the type of links displayed and the other is used for the links. When one is changed, that messes the other up. We can fix that, though. Cool

Change this line:

Code:

$topic_link = 'phpbb';

To:

Code:

$topic_link_type = 'phpbb';


Then change $topic_link to $topic_link_type on these lines:

Code:

            if ($topic_link == 'topic')

Code:

            if ($topic_link == 'phpbb')
 

HB.
Member

Fri May 25, 2007 8:25 pm   Post subject:
Man, you are a life saver Smile

I think it's about time for me to really start learning some of the coding which is involved. Let me ask you, if I were to purchase the phpbb book from the link on this site, would you get any of money from the sale? If so, I would gladly purchase one.
 

Thoul
Administrator

Fri May 25, 2007 9:59 pm   Post subject: Re: Help -- (Topic Extraction) all links lead to the same to
I do get a royalty from each book sold. I get that no matter where it is sold from, so you could use the links here, look it up on a site like Amazon, or buy it from the publisher's site (which is linked on the book page).

Thanks. Smile
 

HB.
Member

Sat Jun 30, 2007 1:18 pm   Post subject: Re: Help -- (Topic Extraction) all links lead to the same to
I know I said something about purchasing the book, but I didn't, but I will. To show my appreciation for you helping me again I sent you another paypal donation today!

Thanks again for all your help thus far!
 

Thoul
Administrator

Sun Jul 01, 2007 12:02 am   Post subject: Re: Help -- (Topic Extraction) all links lead to the same to
Thanks. Smile I'm glad I was able to help.
 

Page 1 of 1
Display posts from previous: