Various modifications for phpBB3Forum Link to Topic Title

Snippets for phpBB3
User avatar

Sniper_E
VIP
VIP
Status: Offline
User theme: Dark
Posts: 1151
Joined: Oct 14th, '14, 17:01
    Windows 8.1 Firefox

Re: Forum Link to Topic Title

Post by Sniper_E »

Just uninstalled this and trying that ext you pointed out.
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!™
User avatar

Jaantje
Users
Users
Status: Offline
User theme: Dark
Posts: 356
Joined: Nov 2nd, '14, 20:25
    Windows 8.1 Chrome

Re: Forum Link to Topic Title

Post by Jaantje »

Thanx dmzx works :tumbsyes:
Grreeetttttzzzzz, Jaantje
User avatar

K3JAE
Users
Users
Status: Offline
User theme: Dark
Posts: 27
Joined: Apr 29th, '16, 10:11
    Windows 7 Firefox

Re: Forum Link to Topic Title

Post by K3JAE »

What exactly needs to be replaced in the newest 3.2 version to get this to work properly? All items in this post have been edited as it states, except the $relative_url; - it does not exist in the newest functions_content file. I guess I should ask is this code change still valid for the 3.2 board?


Open: includes/functions_content.php
Find This may be a partial find and not the whole line

Code: Select all

$text            = $relative_url; 
Replace with Replace the preceding lines with the following

Code: Select all

 $text            = fetch_forumtitle($url);
Find This may be a partial find and not the whole line

Code: Select all

$text    = htmlspecialchars($text);
Replace with Replace the preceding lines with the following

Code: Select all

$text    = str_replace('&', '&', $text);
Find This may be a partial find and not the whole line

Code: Select all

/**
     * make_clickable function
Add before Add these lines on a new blank line before the preceding line(s) to find

Code: Select all

/**
        *  BartVB  Show actual forumname or topic title instead of link to forum URLs
        */
        function fetch_forumtitle($url)
        {
            global $db, $auth;

            // Search for relevant URL parameters (preceded by '?' or 'amp;'
            if(preg_match_all('/(?:\?|&)([ptf])=(\d+)/', $url, $matches))
            {
                $post_id = $topic_id = $forum_id = 0;
                foreach($matches[1] as $set => $param)
                {
                    switch ($param)
                    {
                        case 'p':
                            $post_id = $matches[2][$set];
                            break;
                        case 't':
                            $topic_id = $matches[2][$set];
                            break;
                        case 'f':
                            $forum_id = $matches[2][$set];
                            break;
                    }
                }

                if ($forum_id != 0 && !$auth->acl_get('f_read', $forum_id))
                {
                    return $url;
                }

                if ($topic_id != 0 || $post_id != 0)
                {
                    $sql = "SELECT
                            t.forum_id, topic_title, forum_name " . ($post_id != 0 ? ", username" : "") . "
                        FROM " .
                            ($post_id != 0 ? POSTS_TABLE . " p, " . USERS_TABLE . " u, " : "") .
                            TOPICS_TABLE . " t
                            LEFT JOIN " . FORUMS_TABLE . " f ON (t.forum_id = f.forum_id)
                        WHERE " .
                            ($post_id != 0 ? "post_id = $post_id AND p.topic_id = t.topic_id AND p.poster_id = u.user_id " : "topic_id = " . $topic_id);
                    $result = $db->sql_query($sql);
                    if($row = $db->sql_fetchrow($result))
                    {
                        if (!$auth->acl_get('f_read', $row['forum_id']))
                        {
                            return $url;
                        }

                        $username = ($post_id != 0) ? $row['username'] . " @ " : '';
                        $forum_abbr = (preg_match('/^(\[.+\])/', $row['forum_name'], $matches)) ? $matches[1] . ' ' : '';
                        return $username . $forum_abbr . $row['topic_title'];
                    }
                }
                elseif ($forum_id != 0)
                {
                    $sql = "SELECT forum_name FROM " . FORUMS_TABLE . " WHERE forum_id = " . $forum_id;
                    $result = $db->sql_query($sql);
                    if ($row = $db->sql_fetchrow($result))
                    {
                        return $row['forum_name'];
                    }
                }
            }

            return $url;
        }
User avatar

martin
Admin
Admin
Status: Offline
User theme: Dark
Posts: 5060
Joined: Apr 6th, '14, 14:12
    Ubuntu Chrome

Re: Forum Link to Topic Title

Post by martin »

No longer works on 3.2 there is other ext's out now that do the same but work.
User avatar

K3JAE
Users
Users
Status: Offline
User theme: Dark
Posts: 27
Joined: Apr 29th, '16, 10:11
    Windows 7 Firefox

Re: Forum Link to Topic Title

Post by K3JAE »

Yeah, found out the hard way... Any pointers as to an extension that will do something similar? :whistl:
User avatar

Scanialady
Users
Users
Status: Offline
User theme: Dark
Posts: 310
Joined: Apr 6th, '15, 16:04
    Windows 10 Chrome

Re: Forum Link to Topic Title

Post by Scanialady »

martin wrote: Feb 19th, '17, 20:56 No longer works on 3.2 there is other ext's out now that do the same but work.
Where? Have you a link?
-
If you want to get German translations for extensions: ask me.