Getting HTML into php

Hey everyone! I’ve been trying to get forum content from a phpbb forum to the homepage of my web-site. I have managed to get the content to my page, however I can’t figure out how to format the output. This is mostly due to my utter ignorance of php. The only way I managed to get the content to the web-site is from looking at some other work and after many hours managed to get what I want.

Below is the code for a file called newsfeed.php. I use a php include to get it to my index.php:
[php]

<?php $search_limit = 5; $posts_ary = array( 'SELECT' => 'p.*, t.*, u.username, u.user_colour', 'FROM' => array( POSTS_TABLE => 'p', ), 'LEFT_JOIN' => array( array( 'FROM' => array(USERS_TABLE => 'u'), 'ON' => 'u.user_id = p.poster_id' ), array( 'FROM' => array(TOPICS_TABLE => 't'), 'ON' => 'p.topic_id = t.topic_id' ), ), 'WHERE' => $db->sql_in_set('t.forum_id', array_keys($auth->acl_getf('f_read', true))) . ' 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']; $post_author = get_username_string('full', $posts_row['poster_id'], $posts_row['username'], $posts_row['user_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' => $post_author, 'POST_DATE' => $post_date, 'POST_LINK' => $post_link, 'POST_TEXT' => censor_text($post_text), )); } $template->set_filenames(array( 'body' => 'external_body.html' )); $template->display('body'); ?>

[/php]

Basically what I’m trying to do is get some divs into the output so that I can style it with CSS. Could anyone help me get into the right direction?

Thanks so much for taking the time to read my question! :slight_smile:

You’re editing the wrong page. That’s just a config page and i think you can edit the templates right through the admin page.

Hey, thanks for the reply!

I tried to edit the external_body.html page but it seemed like everything I did seemed to do nothing. Is there something I might be doing wrong?

Thanks again for the reply :smiley:

make sure you’re using the right one. There’s probably one for each template you have installed.

You don’t need to modify ANY of the phpbb files. All you need is the db login info, a SELECT query and just loop through the result row by row posting the news.

For formatting, you most likely need to parse the PHPBB Code, and you’ll also want to use nl2br to change all the newlines to
tags.

Sponsor our Newsletter | Privacy Policy | Terms of Service