Forum Link to Topic Title

Mixed forum with code snippets, guides and styles
Forum rules
Everything in this forum is for everybody
But support only for Donators!
User avatar
Stoker
Site Admin
Site Admin
Posts: 3511
Joined: 12 May 2008, 21:26
BBCodes: 239
Favourite BBCode: Anipro
Favourite MOD: PrettyPhoto
Location: Denmark

Forum Link to Topic Title

Post by Stoker » 14 Apr 2012, 07:36

Forum Link to Topic Title
Written by BartVB and 4_seven

This is one of the forgotten snippets.
It changes internal links to topic title.

Internal forum link example: Top Stats
Internal forum topic example: viewtopic.php?f=37&t=1346
Internal forum post example: General Error (Post by KreatorTeam #8664)

Open: includes/functions_content.php
Find:

Code: Select all

$text            = $relative_url; 
Replace with:

Code: Select all

$text            = fetch_forumtitle($url);
Find:

Code: Select all

$text    = htmlspecialchars($text);
Replace with:

Code: Select all

$text    = str_replace('&', '&', $text);
Find:

Code: Select all

/**
 * make_clickable function
Add before:

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;
    } 
Board rules! No PM support
Sure, I can install the Mod for you ;)
Like the site? Then buy me a bear


User avatar
martin123456
BBCoder VI
BBCoder VI
Posts: 764
Joined: 25 Jul 2011, 11:29
BBCodes: 34
Favourite MOD: Ban button
Location: Down south!

Forum Link to Topic Title

Post by martin123456 » 14 Apr 2012, 10:03

This should be default in phpbb but it's not.
:D

User avatar
kevinviet
BBCoder III
BBCoder III
Posts: 123
Joined: 06 Mar 2010, 02:52

Forum Link to Topic Title

Post by kevinviet » 14 Apr 2012, 21:03

Thanks Stoker :thumb:

User avatar
kevinviet
BBCoder III
BBCoder III
Posts: 123
Joined: 06 Mar 2010, 02:52

Forum Link to Topic Title

Post by kevinviet » 18 May 2012, 05:34

After the edited, on my board the link with www is work great but the link without www doesn't work. Any idea fixing it Stoker ?

User avatar
Stoker
Site Admin
Site Admin
Posts: 3511
Joined: 12 May 2008, 21:26
BBCodes: 239
Favourite BBCode: Anipro
Favourite MOD: PrettyPhoto
Location: Denmark

Forum Link to Topic Title

Post by Stoker » 18 May 2012, 06:05

Nope, but you can ask the author here: http://www.phpbb.com/community/viewtopi ... &t=2092969
Board rules! No PM support
Sure, I can install the Mod for you ;)
Like the site? Then buy me a bear


User avatar
kevinviet
BBCoder III
BBCoder III
Posts: 123
Joined: 06 Mar 2010, 02:52

Forum Link to Topic Title

Post by kevinviet » 18 May 2012, 06:13

Thanks Stoker, will go there :D

User avatar
Solidjeuh
BBCoder IV
BBCoder IV
Posts: 257
Joined: 16 Oct 2011, 00:15
BBCodes: 7
Favourite MOD: Top stats
Location: Aalst / Belgium

Forum Link to Topic Title

Post by Solidjeuh » 21 Jun 2012, 21:15

Is this also possible for the phpbb arcade?
For the announcements in Mchat when new games are added..
Cause those announcements still shows the link, And not the topic tittle
Yeah I'm crazy.. So What!?! Live Your Life The Way You Want It To be!
Download +30.000 arcade extension games @ ~ http://www.froddelpower.be ~

User avatar
Stoker
Site Admin
Site Admin
Posts: 3511
Joined: 12 May 2008, 21:26
BBCodes: 239
Favourite BBCode: Anipro
Favourite MOD: PrettyPhoto
Location: Denmark

Forum Link to Topic Title

Post by Stoker » 22 Jun 2012, 04:46

Try ask the arcade author. He might have the solution.
Board rules! No PM support
Sure, I can install the Mod for you ;)
Like the site? Then buy me a bear

User avatar
Nully
Donator
Donator
Posts: 258
Joined: 14 Mar 2010, 22:03
BBCodes: 10
Favourite MOD: Radios
Location: France > Bulgaria

Forum Link to Topic Title

Post by Nully » 22 Jun 2012, 05:51

I like it. Thanks Stoker :D

User avatar
Rhyno
BBCoder III
BBCoder III
Posts: 100
Joined: 25 Jan 2012, 04:06
BBCodes: 10
Favourite MOD: Top Stats
Location: Australia

Forum Link to Topic Title

Post by Rhyno » 14 Aug 2013, 04:52

This still work on 3.0.11 ?