Jump to content

PHPBB3 top articles.


Recommended Posts

Hi I installed a PHPBB3 mod called Evaluate Topics that way I can rank articles on my forums. The mod works perfectly now however I need to link that to my main page so I can have a top articles section. :) Here's the code I use to do this..

 

    <?php
    $output = '';

    //-- Fetch the data from the specified fora
    $news_fora_id = array( '19' ); // Change in the fora id's you need
$topic_count = '1'; // Change in the number of topics you want to show.
    $query = "
            SELECT p.topic_id, p.forum_id, p.post_time, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid,
                u.user_id, u.user_email, u.username, u.user_posts, u.user_rank, u.user_colour, u.user_allow_viewonline, u.user_allow_viewemail,
                t.topic_title,
                    (
                        SELECT COUNT( post_id )
                        FROM " . POSTS_TABLE . "
                            WHERE topic_id = p.topic_id
                    ) AS aantal_posts
            FROM " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u, " . TOPICS_TABLE . " AS t ". TOPICS_EVALUATION_TABLE ." AS e
                WHERE " . $db->sql_in_set( 'p.forum_id', $news_fora_id ) . "
                    AND u.user_id = p.poster_id
                    AND t.topic_id = p.topic_id
            GROUP BY evaluation
            ORDER BY evaluation DESC
            LIMIT 0, {$topic_count}
        ";

    //die('<pre>' . $query );
    $result = $db->sql_query( $query );
    while( $row = $db->sql_fetchrow($result) )
    {
        // Send data to output var
        $output .= "<h2><a href=\"" . $phpbb_root_path . "viewtopic.php?f={$row['forum_id']}&t={$row['topic_id']}\" title=\""  . censor_text($row['post_subject']) . "\">-".censor_text($row['post_subject'])."</a></h2>\n";
        //$output .= "<p style=\" padding-bottom: 3em; \">\n\t";
    }

    // print the output
    print( $output );
    ?>

 

And here's the test page I setup to test this out: http://shaderguru.x10hosting.com/test.php

 

I know the PHPBB3 headers are already sent so that shouldn't be a problem. I also need to know how to make it so it loops throught more then one forum as I have 4 article forums that need to be checked for top articles. You can see my forums here: http://shaderguru.x10hosting.com/forums/index.php

 

Edit: In case your wondering my ranks are stored in a mySQL database under the table "phpbb_topics_evaluation". It has topic_id, evaluation, and user_id in the table.

 

Thanks for any help,

-Toaster

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.