0 Replies - 4597 Views - Last Post: 20 December 2012 - 04:12 PM Rate Topic: -----

#1 Skunny  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 12-March 12

Displaying forum topics with images on homepage (phpbb forum)

Posted 20 December 2012 - 04:12 PM

Hey everyone, I am having trouble with displaying the content in posts from a specific forum on my phpbb forums on my websites homepage.

What i want is for the homepage to pull the contents of the post in between the [img] tags and display the said image on my homepage and that image to the forum post itself.

Here is my home.php (the first page you see when going to the site):
<?php
    //This page displays the list of the forum's categories
    include('config.php');
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
        
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        
        <link href="css/style.css" rel="stylesheet" title="Style" />     
        <link href="css/nav.css" rel="stylesheet" title="Style" />
        
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
        <script type="text/javascript" src="js/nav_fade.js"></script>
    
        <title></title>
        
    </head>
    
    <body>
        
        <?php
            include('header.php');
        ?>
    
            <div id="content">
                    
                <div id="content_cen">
                    
                    <?php
                       include('newposts.php');
                    ?>
                    
                </div>
                
            </div>
        
        <?php
            include('footer.php');
        ?>
        
    </body>
    
</html>




Here is the newposts.php which is supposed to pull the recent most 10 topics from the "News" forum under my "Public Forums" category:

<?php

    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './forum/';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);

    // Start session management
    //$user->session_begin();
    //$auth->acl($user->data);
    //$user->setup();

    // Number of posts and grabbing permissions
    // Pocet prspevku pro zobrazen a oprvnen
    $topic_limit = request_var('topic_limit', 5);
    $forums = array_unique(array_keys($auth->acl_getf('f_read', true))); //ignored in sql statement to include all topics despite permissions

    // Select the last topics based on user permissions
    /* $sql = 'SELECT p.post_id, p.topic_id, p.forum_id, p.post_subject, p.post_time, u.username
                        FROM ' . POSTS_TABLE . ' p , ' . USERS_TABLE . ' u
                        WHERE post_approved = 1
                            AND ' . $db->sql_in_set('forum_id', $forums) . '
                            AND u.user_id = p.poster_id
                        ORDER BY post_time DESC
                        LIMIT 0,' . $topic_limit;
        $result = $db->sql_query($sql); */

    // Select the last topics ignoring permissions
    // Vybrat posledn tmata ke kterm mme oprvnen
    $sql = 'SELECT p.post_id, p.topic_id, p.forum_id, p.post_subject, p.post_time, u.username
                    FROM ' . POSTS_TABLE . ' p , ' . USERS_TABLE . ' u
                    WHERE post_approved = 1
                        AND  u.user_id = p.poster_id
                    ORDER BY post_time DESC
                    LIMIT 0,' . $topic_limit;
    $result = $db->sql_query($sql);

    // Proper header since output not buffered
    // Poslat hlavicky pro sprvn kdovn, protoe vpis obsahu je postupn
    //    header('Content-Type: text/html; charset=utf-8');

    // Now let's output the content
    // A ted vypsat obsah
    //    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Last Topics</title></head><body><div id="post_content"><strong>Last Topics:</strong><br/><ul>';
    while ($row = $db->sql_fetchrow($result))
    {
        $url = generate_board_url() . "/viewtopic.{$phpEx}?f={$row['forum_id']}&amp;t={$row['topic_id']}&amp;p={$row['post_id']}#p{$row['post_id']}"; //added fedforum to url

    //old line $url = generate_board_url() . "viewtopic.{$phpEx}?f={$row['forum_id']}&amp;t={$row['topic_id']}&amp;p={$row['post_id']}#p{$row['post_id']}";
        echo '<tr><td colspan=\"2\"><a target="_blank" href="' . $url . '">' . $row['post_subject'] . '</a>, ' . ucwords($row['username']) . ', ' . date("d/m Hi",$row['post_time']).'hrs</td></tr>';
    }
    echo '</div></body></html>';
    ?>



All that it displays is the forums topic title (linking that title to the forum post) and the author of that topic.
I instead want it to pull the contents of whats in between the image tags and display the image (linking it to the forum post) as well as having the author of the post at the top centered above the image.

I am not very good with sql and queries so I am not sure how this is done, any help would be greatly appreciated.

examples of what I am talking about can be found on pretty much any guild website for world of warcraft etc. but something like: http://www.tsmguild.net/ would be what I am looking to do.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1