Problem with Displaying Topics/Posts on external page #9001

All web design discussion, including Ultimate Quiz MOD support.

Moderator: CricketMX Forum Moderators

Re: Problem with Displaying Topics/Posts on external page #9

Postby TheGiftedApe » Thu Dec 01, 2011 5:17 am

I GOT IT YEEEEEEEEEEEEEEEEEEEAH

so my problem was i was putting the php code right in the middle of the div. I found the help here: http://www.phpfreaks.com/forums/index.p ... c=317350.0

You cant output the php stuff after the html, it has to be first, so I split up the code like this.
Code: Select all
<?php include("tester2.php"); ?>
<html>
<head>
<title>Team xO Gaming - Hug's N Kisses!!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="class.css">
<script type="text/javascript">
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
</head>
<body style="background-color:#000000; margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;" onLoad="MM_preloadImages('images/xoweb_over_03.png','images/xoweb_over_04.png','images/xoweb_over_05.png','images/xoweb_over_07.png','images/xoweb_over_08.png','images/xoweb_over_09.png')">
<center>
<div id="Table_01">
   <div id="xoweb-01">
      <img src="images/xoweb_01.png" width="1000" height="63" alt="">
   </div>
   <div id="xoweb-02">
      <img src="images/xoweb_02.png" width="210" height="81" alt="">
   </div>
   <div id="xoweb-03"> <a href="#news" target="_self"><img src="images/xoweb_03.png" alt="" width="62" height="33" border="0" id="Image1" onMouseOver="MM_swapImage('Image1','','images/xoweb_over_03.png',1)" onMouseOut="MM_swapImgRestore()"></a>
</div>
   <div id="xoweb-04"> <a href="roster.php" target="_self"><img src="images/xoweb_04.png" alt="" width="80" height="33" border="0" id="Image2" onMouseOver="MM_swapImage('Image2','','images/xoweb_over_04.png',1)" onMouseOut="MM_swapImgRestore()"></a>
</div>
   <div id="xoweb-05"> <a href="http://www.xo-gaming.com/forum/" target="_new"><img src="images/xoweb_05.png" alt="" width="76" height="33" border="0" id="Image3" onMouseOver="MM_swapImage('Image3','','images/xoweb_over_05.png',1)" onMouseOut="MM_swapImgRestore()"></a>
</div>
   <div id="xoweb-06">
      <img src="images/xoweb_06.png" width="164" height="81" alt="">
   </div>
   <div id="xoweb-07"> <a href="#" target="_self"><img src="images/xoweb_07.png" alt="" width="95" height="33" border="0" id="Image4" onMouseOver="MM_swapImage('Image4','','images/xoweb_over_07.png',1)" onMouseOut="MM_swapImgRestore()"></a>
   </div>
   <div id="xoweb-08"> <a href="#" target="_self"><img src="images/xoweb_08.png" alt="" width="60" height="33" border="0" id="Image5" onMouseOver="MM_swapImage('Image5','','images/xoweb_over_08.png',1)" onMouseOut="MM_swapImgRestore()"></a>
   </div>
   <div id="xoweb-09"> <a href="http://www.xo-gaming.com/forum/viewforum.php?f=8" target="_self"><img src="images/xoweb_09.png" alt="" width="61" height="33" border="0" id="Image6" onMouseOver="MM_swapImage('Image6','','images/xoweb_over_09.png',1)" onMouseOut="MM_swapImgRestore()"></a>
</div>
   <div id="xoweb-10">
      <img src="images/xoweb_10.png" width="192" height="81" alt="">
   </div>
   <div id="xoweb-11">
      <img src="images/xoweb_11.png" width="218" height="48" alt="">
   </div>
   <div id="xoweb-12">
      <img src="images/xoweb_12.png" width="216" height="48" alt="">
   </div>
<div id="xoweb-13" align="left" >
        <?php
          $template->set_filenames(array(
        'body' => 'external_body.html'
    ));

    page_footer();
   ?>
<center>© 2011 <a href="http://www.thegiftedape.com/xo/">Team xO,</a> <a href="http://www.thegiftedape.com">TheGiftedApe llc.</a></center></div>
</center>
</body>
</html>


tester2.php code:
Code: Select all
<?php
/*
* home.php
* Description: example file for displaying latest posts and topics
* by battye (for phpBB.com MOD Team)
* September 29, 2009
*/

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);
include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');
/* create_where_clauses( int[] gen_id, String type )
* This function outputs an SQL WHERE statement for use when grabbing
* posts and topics */

function create_where_clauses($gen_id, $type)
{
global $db, $auth;

    $size_gen_id = sizeof($gen_id);

        switch($type)
        {
            case 'forum':
                $type = 'forum_id';
                break;
            case 'topic':
                $type = 'topic_id';
                break;
            default:
                trigger_error('No type defined');
        }

    // Set $out_where to nothing, this will be used of the gen_id
    // size is empty, in other words "grab from anywhere" with
    // no restrictions
    $out_where = '';

    if( $size_gen_id > 0 )
    {
    // Get a list of all forums the user has permissions to read
    $auth_f_read = array_keys($auth->acl_getf('f_read', true));

        if( $type == 'topic_id' )
        {
            $sql     = 'SELECT topic_id FROM ' . TOPICS_TABLE . '
                        WHERE ' .  $db->sql_in_set('topic_id', $gen_id) . '
                        AND ' .  $db->sql_in_set('forum_id', $auth_f_read);

            $result     = $db->sql_query($sql);

                while( $row = $db->sql_fetchrow($result) )
                {
                        // Create an array with all acceptable topic ids
                        $topic_id_list[] = $row['topic_id'];
                }

            unset($gen_id);

            $gen_id = $topic_id_list;
            $size_gen_id = sizeof($gen_id);
        }

    $j = 0;   

        for( $i = 0; $i < $size_gen_id; $i++ )
        {
        $id_check = (int) $gen_id[$i];

            // If the type is topic, all checks have been made and the query can start to be built
            if( $type == 'topic_id' )
            {
                $out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' ';
            }

            // If the type is forum, do the check to make sure the user has read permissions
            else if( $type == 'forum_id' && $auth->acl_get('f_read', $id_check) )
            {
                $out_where .= ($j == 0) ? 'WHERE ' . $type . ' = ' . $id_check . ' ' : 'OR ' . $type . ' = ' . $id_check . ' ';
            }   

        $j++;
        }
    }

    if( $out_where == '' && $size_gen_id > 0 )
    {
        trigger_error('A list of topics/forums has not been created');
    }

    return $out_where;
}

$search_limit = 5;

    $forum_id = array(17);
    $forum_id_where = create_where_clauses($forum_id, 'forum');

    $topic_id = array();
    $topic_id_where = create_where_clauses($topic_id, 'topic');
$posts_ary = array(
        'SELECT'    => 'p.*, t.*',
   
        'FROM'      => array(
            POSTS_TABLE     => 'p',
        ),
   
        'LEFT_JOIN' => array(
            array(
                'FROM'  => array(TOPICS_TABLE => 't'),
                'ON'    => 't.topic_first_post_id = p.post_id'
            )
        ),
   
        'WHERE'     => str_replace( array('WHERE ', 'forum_id'), array('', 't.forum_id'), $forum_id_where) . '
                        AND t.topic_status <> ' . ITEM_MOVED . '
                        AND t.topic_approved = 1',
   
        'ORDER_BY'  => 'p.post_id DESC',
    );
   
    $posts = $db->sql_build_query('SELECT', $posts_ary);

   $posts_result = $db->sql_query_limit($posts, $search_limit);

       while( $posts_row = $db->sql_fetchrow($posts_result) )
      {
         $topic_title       = $posts_row['topic_title'];
         $topic_author       = get_username_string('full', $posts_row['topic_poster'], $posts_row['topic_first_poster_name'], $posts_row['topic_first_poster_colour']);
         $post_date          = $user->format_date($posts_row['post_time']);
         $post_link       = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=" . $posts_row['post_id'] . "#p" . $posts_row['post_id']);
       $post_text = nl2br($posts_row['post_text']);

         $bbcode = new bbcode(base64_encode($bbcode_bitfield));         
         $bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']);

         $post_text = smiley_text($post_text);

          $template->assign_block_vars('announcements', array(
         'TOPIC_TITLE'       => censor_text($topic_title),
         'POST_AUTHOR'       => $topic_author,
         'POST_DATE'       => $post_date,
         'POST_LINK'       => $post_link,
         'POST_TEXT'         => censor_text($post_text),
         ));
      }
 
?>


external body code for those interested:
Code: Select all
<!-- BEGIN announcements -->
<b><span style="font-size:28px; color:#ccc;">{announcements.TOPIC_TITLE}</span></b><br /><br />
Author: {announcements.POST_AUTHOR}<br />
Date:<b> {announcements.POST_DATE}</b><br />
<br /><b>{announcements.POST_TEXT}</b><br />
<h5><b><a href="{announcements.POST_LINK}">Read/Post Comments</a></b></h5><br /><br /><br />
<!-- END announcements -->


and all the code for pulling the forum articles is in the tester2.php file, works perfectly now and programming the css on the external_body file is super easy. THANK YOU SO MUCH FOR ALL YOUR HELP!!!


The end product can be viewed at http://xo-gaming.com

/thread
User avatar
TheGiftedApe
Greenhorn
Greenhorn
 
Posts: 16
Joined: Mon Nov 07, 2011 5:41 am

Re: Problem with Displaying Topics/Posts on external page #9

Postby SMCaD » Fri Feb 17, 2012 11:12 pm

Thanks for keeping this available!
The questions that TheGiftedApe asked and the answers that were give were perfect for my questions that I was having.
I just couldn't figure out why I couldn't pull the Forum/Topics/Posts into the coding...
I was super confused.


Now on to Styling my page to match the Style on the forum... that's the easy part.

http://dotrf.wyldb.net/News.php is the page that needs styled now.

Again, THANKS! =D>
SMCaD
Greenhorn
Greenhorn
 
Posts: 9
Joined: Fri Feb 17, 2012 10:39 pm

Previous

Return to Web Design

Who is online

Users browsing this forum: No registered users and 2 guests

cron