[Snippet] Topic-ID on Index

Little Mods and Snips 3

[Snippet] Topic-ID on Index

Postby Sekuro » 01 Oct 2011, 18:00

Topic-ID on Index

Make that all links to posts from index-page contains topic-id's (even if a 'last_post' is present)

May helpfull for Snippets/Mods or as Inspiration

To make this possible, it adds 2 additional SQL Queries to your board

open

index.php

find

Code: Select all
    // Output page
    page_header($user->lang['INDEX']); 

before add

Code: Select all
    // Topic-ID on Index / 4seven / 2011
        if (($user->data['user_id'] !== ANONYMOUS) && !$user->data['is_bot'])
        {
        
        $config_row_forum_last_post_id 
= explode(',', $config[(int)$user->data['user_id'] . '_last_post_id']);
        
            $sql 
= 'SELECT forum_id, topic_id, post_id
                    FROM '
 . POSTS_TABLE . '
                    WHERE '
 . $db->sql_in_set('post_id', $config_row_forum_last_post_id) . '
                    GROUP BY forum_id'
;
            $result = $db->sql_query_limit($sql, sizeof($config_row_forum_last_post_id));

            $topic_id_format = append_sid($phpbb_root_path . 'viewtopic.' . $phpEx, array('f' => '%1$s', 't' => '%2$s', 'p' => '%3$s', '#' => 'p' . '%3$s'));
            
            $config_row_forum_last_post_id 
= array_flip($config_row_forum_last_post_id);

        while ($row = $db->sql_fetchrow($result)){
     
            $rownr 
= $config_row_forum_last_post_id[$row['post_id']];
            
            $topic_id_url 
= sprintf($topic_id_format, $row['forum_id'], $row['topic_id'], $row['post_id']);
            

            $template
->alter_block_array('forumrow', array(
         
                     
'U_LAST_POST' => $topic_id_url
                     
            
), $rownr, 'change');}
     
            $db
->sql_freeresult($result);

        }
    // Topic-ID on Index / 4seven / 2011       

open

includes/functions_display.php

find

Code: Select all
        foreach ($forum_rows as $row)
        

after add

Code: Select all
            // Topic-ID on Index / 4seven / 2011
            $row_forum_last_post_id[] = $row['forum_last_post_id'];
            // Topic-ID on Index / 4seven / 2011        

find

Code: Select all
            $last_catless = $catless;
        

after add

Code: Select all
        // Topic-ID on Index / 4seven / 2011
        if (($user->data['user_id'] !== ANONYMOUS) && !$user->data['is_bot']){
        $row_forum_last_post_id = implode(',', $row_forum_last_post_id);
        if(isset($config[(int)$user->data['user_id'] . '_last_post_id'])){
        if($row_forum_last_post_id !==  $config[(int)$user->data['user_id'] . '_last_post_id']){
        set_config((int)$user->data['user_id'] . '_last_post_id', $row_forum_last_post_id);}}
        else{set_config((int)$user->data['user_id'] . '_last_post_id', $row_forum_last_post_id);}}
        // Topic-ID on Index / 4seven / 2011         


Note: You must be logged in at least 1 time as normal user, to see it as guest..
Mod-Bot / Service-Team
User avatar
Sekuro

Tiptop

Tiptop
 
Posts: 241
Joined: 11 Feb 2008, 11:49
 
Resolution: 1440x900


Return to Snip Cl@ss III

Who is online

Users browsing this forum: No registered users and 1 guest

cron