Website/ board intigration

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Astaldaran
Registered User
Posts: 41
Joined: Thu Apr 17, 2003 11:01 pm
Contact:

Website/ board intigration

Post by Astaldaran »

Hey I am looking into intigrating my boards and my website togethor to make them "like" the same thnig. I am not sure if you know what i mean... so

Ok i mean kind of liek on this site, you don't have to be in the boards to be able to log on and such. That is how i want my site, only once i start getting familiar with these boards ill be maknig it more advanced.

I have been learning php so i am not a pro yet but im ok :)


Well anyway here is what i would like help with first (like i said im a newb so it will take me some time to get use to messing with phpbb)



I want on my site to have the login info (if you are loged in, and if not the name password thing) , the buttons at the top (FAQ,search,memberlist,etc) and the wholee section of users online.


I am currently approaching it by copying portionos of the index.php... it isn't working. so what i want is really jsut an explanation on how to do it.



Thanks!!
netclectic
Former Team Member
Posts: 4439
Joined: Wed Mar 13, 2002 3:08 pm
Location: Omnipresent
Contact:

Post by netclectic »

moved to MOD Authors Support Forum
Defend the game:
Image
Astaldaran
Registered User
Posts: 41
Joined: Thu Apr 17, 2003 11:01 pm
Contact:

web/board intigration

Post by Astaldaran »

hey sry about that, it wasn't til li pushed post that i realized i had put it in the wrong place.


I was thinking instead of trying to inigrate my boards into my site; would it be easier to inigrate my site into my boards?


thx
User avatar
Smidge204
Registered User
Posts: 23
Joined: Sun Feb 09, 2003 8:50 am

Post by Smidge204 »

If your site and board are hosted on the same account, then integration would be a snap - at least in terms of sharing data back and forth.

How you would integrate the two depends very much on exactly what you want to accomplish by doing so. Personalized home pages (ie: "Welcome back, User42!") or keeping track of forms and the like?

If all you want to do is make the two feel the same, that's more of a site design issue than a php scripting one.

Just have to define exactly what you want to accomplish and we can work from there. :D
=Smidge=
Astaldaran
Registered User
Posts: 41
Joined: Thu Apr 17, 2003 11:01 pm
Contact:

ok// lets try this one step at a time

Post by Astaldaran »

Ok my site is www.redemptionohio.com (yeah it has a few problem right now; (don't ask me where they came from) bu ill fix them later)

Ok my boards are located at

www.redemptionohio.com/boards



WHat i want to do is inigrate the two so they don't just look the same, they are the same (sort of)

Ok first of all i want to be able for you to log in and see who is online and such

(this link is helping some " http://www.phpbb.com/kb/article.php?article_id=18 " )

so i tried this code ( you can see what this looks like on my site by gonig to " www.redemptionohio.com/index.php


<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
<tr>
<td class="catHead" colspan="2" height="28"><span class="cattitle"><a href="{U_VIEWONLINE}" class="cattitle">{L_WHO_IS_ONLINE}</a></span></td>
</tr>
<tr>
<td class="row1" align="center" valign="middle" rowspan="2"><img src="boards/templates/subSilver/images/whosonline.gif" alt="{L_WHO_IS_ONLINE}" /></td>
<td class="row1" align="left" width="100%"><span class="gensmall">{TOTAL_POSTS}<br />{TOTAL_USERS}<br />{NEWEST_USER}</span>
</td>
</tr>
<tr>
<td class="row1" align="left"><span class="gensmall">{TOTAL_USERS_ONLINE} & [ {L_WHOSONLINE_ADMIN} ] & [ {L_WHOSONLINE_MOD} ]<br />{RECORD_USERS}<br />{LOGGED_IN_USER_LIST}</span></td>
</tr>
</table>

<table width="100%" cellpadding="1" cellspacing="1" border="0">
<td align="left" valign="top"><span class="gensmall">{L_ONLINE_EXPLAIN}</span></td>
</table>

but it is isn't showing up right, i am guessing this is because it does not have an include or something. I am not sure since that article din't specify.
User avatar
Smidge204
Registered User
Posts: 23
Joined: Sun Feb 09, 2003 8:50 am

Post by Smidge204 »

"I see..." said the blind carpenter, as he picked up his hammer and saw...

Okey dokey. doesn't seem unreasonable. I have on real clue how to do it myself, but nobody ever does on their first try :D

First things first: I'd like to actually see the code in hte index.php file. If it's not too big you can post it here, in the 'code' tags, or if it's a lot maybe you could save it as a .txt file and upload it to your website?

Next, you'll need to make a template file if you don't already have one. Since I can't see the php code, I have no idea if you've got one... but since I see things like {TOTAL_POSTS} I'm guessing it's not quite right.

A template file (*.tpl) is pretty much the body of the resulting HTML file you want, except with all the synamic content replaced with tags enclosed in wavy brackets: {}

Using the template processing abilities of phpbb, you can write your code to incorperate the dynamic content and then parse the template files to generate the final page. All of the parsing is done automatically, so it's a real breeze: Just tell it what template to use and what the various chunks of data youy want put it in, and off it goes!

Here's an example snippet from the total rebuild of 's shop mod I'm working on: (Extra code removed for clarity! Replaced with (...)!)

Code: Select all

for ($er = 0; $er < mysql_num_rows($result); $er++)
{

(...)
	// Add shop title header stuff
	$template->assign_block_vars('shoprow', array('SHOP_NAME' => $shop));

	// iterate every item in this shop
	for ($erB = 0; $erB < $numrows; $erB++)
	{
		(...)
		$template->assign_block_vars('shoprow.itemrow', array(
			'ITEM_NAME' => ucwords($row['name']),
			'ITEM_ACTION' => $itemaction,
			'ITEM_DESC' => $itemdesc,
			'ITEM_SOLD' => $row['sold'],
			'ITEM_STOCK' => ($row['stock'] == -1) ? '----' : (($row['stock'] == 0) ? "Sold out!": $row['stock']),
			'ITEM_COST' => $row['cost']
		) );
		}
	}
} // next shop
And the accompanying template file: (Again, chunks removed for clarity)

Code: Select all

	<!-- BEGIN shoprow -->
	<tr>
	<td class="row1" colspan=2><span class="gen"><b>{shoprow.SHOP_NAME}</b></span></td>
	 <td class="row1" width=6%><span class="gen">Sold</span></td>
	 <td class="row1" width=6%><span class="gen">Stock</span></td>
	 <td class="row1" width=6%><span class="gen">Cost</span></td>
	</tr>

	<!-- BEGIN itemrow -->
	<tr>
	 <td class="row1"><span class="gensmall"><b><a href="(...)">{shoprow.itemrow.ITEM_NAME}</b></a> {shoprow.itemrow.ITEM_ACTION}</span></td>
	 <td class="row2"><span class="gensmall">{shoprow.itemrow.ITEM_DESC}</span></td>
	 <td class="row2"><span class="gensmall">{shoprow.itemrow.ITEM_SOLD}</span></td>
	 <td class="row2"><span class="gensmall">{shoprow.itemrow.ITEM_STOCK}</span></td>
	 <td class="row2"><span class="gensmall">{shoprow.itemrow.ITEM_COST}</span></td>
	</tr>	
	<!-- END itemrow -->
	<!-- END shoprow -->
That may be a slightly overcomplicated example, since it involves loops. However, the idea is that the template parser will automatically repeat chunks of HTML to use up all the data you give to it, providing you input the data properly. But overall it's the same.

That might get you started! Try making a template and using php code to stuff some constants in there just to get the feel for it.

P.S. Hope I'm not telling you anything you already knew :P
=Smidge=
Astaldaran
Registered User
Posts: 41
Joined: Thu Apr 17, 2003 11:01 pm
Contact:

Post by Astaldaran »

lets see so i messed up, i never made a template file. Which is one of the reasons i was so confused i wasn't seeing where this that bit of html was getting it properties.

I have never made a template file so i ahve a few questions:


Is a template file html or somethnig else? (since i don't see any php tags,etc)

so a template file is what spits out the site and the code jsut says what the different properties of the template is?
User avatar
GPHemsley
Registered User
Posts: 1475
Joined: Fri Apr 18, 2003 3:12 am
Location: Long Beach, NY
Name: Gordon Hemsley
Contact:

Post by GPHemsley »

A template file is made of HTML coding and variables that are defined in the corresponding PHP file.
Astaldaran
Registered User
Posts: 41
Joined: Thu Apr 17, 2003 11:01 pm
Contact:

Post by Astaldaran »

does anyone know of a good tutorial on templates (or at least a more therough explanation of how they work) i looked around some but havent found it.
Astaldaran
Registered User
Posts: 41
Joined: Thu Apr 17, 2003 11:01 pm
Contact:

Post by Astaldaran »

ok i believe i got the whole template thing, but where i ran into the problem is there is no code! WHen i was reading ttrhough the tutorial this is what got me so confused i didn't get where it was getting this stuff. I am still confused.


Ok so how do i make it check for users online and such

this is the code from the index file that does this, i think this is all. is there anythnig else i need?



"


//
// Get basic (usernames + totals) online
// situation
//
$logged_visible_online = 0;
$logged_hidden_online = 0;
$guests_online = 0;
$online_userlist = '';

if (defined('SHOW_ONLINE'))
{

$user_forum_sql = ( !empty($forum_id) ) ? "AND s.session_page = " . intval($forum_id) : '';
$sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_ip
FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
WHERE u.user_id = s.session_user_id
AND s.session_time >= ".( time() - 300 ) . "
$user_forum_sql
ORDER BY u.username ASC, s.session_ip ASC";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain user/online information', '', __LINE__, __FILE__, $sql);
}

$userlist_ary = array();
$userlist_visible = array();

$prev_user_id = 0;
$prev_user_ip = '';

while( $row = $db->sql_fetchrow($result) )
{
// User is logged in and therefor not a guest
if ( $row['session_logged_in'] )
{
// Skip multiple sessions for one user
if ( $row['user_id'] != $prev_user_id )
{
$style_color = '';
if ( $row['user_level'] == ADMIN )
{
$row['username'] = '<b>' . $row['username'] . '</b>';
$style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
}
else if ( $row['user_level'] == MOD )
{
$row['username'] = '<b>' . $row['username'] . '</b>';
$style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
}

if ( $row['user_allow_viewonline'] )
{
$user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'>' . $row['username'] . '</a>';
$logged_visible_online++;
}
else
{
$user_online_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $style_color .'><i>' . $row['username'] . '</i></a>';
$logged_hidden_online++;
}

if ( $row['user_allow_viewonline'] || $userdata['user_level'] == ADMIN )
{
$online_userlist .= ( $online_userlist != '' ) ? ', ' . $user_online_link : $user_online_link;
}
}

$prev_user_id = $row['user_id'];
}
else
{
// Skip multiple sessions for one user
if ( $row['session_ip'] != $prev_session_ip )
{
$guests_online++;
}
}

$prev_session_ip = $row['session_ip'];
}
$db->sql_freeresult($result);

if ( empty($online_userlist) )
{
$online_userlist = $lang['None'];
}
$online_userlist = ( ( isset($forum_id) ) ? $lang['Browsing_forum'] : $lang['Registered_users'] ) . ' ' . $online_userlist;

$total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online;

if ( $total_online_users > $board_config['record_online_users'])
{
$board_config['record_online_users'] = $total_online_users;
$board_config['record_online_date'] = time();

$sql = "UPDATE " . CONFIG_TABLE . "
SET config_value = '$total_online_users'
WHERE config_name = 'record_online_users'";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update online user record (nr of users)', '', __LINE__, __FILE__, $sql);
}

$sql = "UPDATE " . CONFIG_TABLE . "
SET config_value = '" . $board_config['record_online_date'] . "'
WHERE config_name = 'record_online_date'";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update online user record (date)', '', __LINE__, __FILE__, $sql);
}
}

if ( $total_online_users == 0 )
{
$l_t_user_s = $lang['Online_users_zero_total'];
}
else if ( $total_online_users == 1 )
{
$l_t_user_s = $lang['Online_user_total'];
}
else
{
$l_t_user_s = $lang['Online_users_total'];
}

if ( $logged_visible_online == 0 )
{
$l_r_user_s = $lang['Reg_users_zero_total'];
}
else if ( $logged_visible_online == 1 )
{
$l_r_user_s = $lang['Reg_user_total'];
}
else
{
$l_r_user_s = $lang['Reg_users_total'];
}

if ( $logged_hidden_online == 0 )
{
$l_h_user_s = $lang['Hidden_users_zero_total'];
}
else if ( $logged_hidden_online == 1 )
{
$l_h_user_s = $lang['Hidden_user_total'];
}
else
{
$l_h_user_s = $lang['Hidden_users_total'];
}

if ( $guests_online == 0 )
{
$l_g_user_s = $lang['Guest_users_zero_total'];
}
else if ( $guests_online == 1 )
{
$l_g_user_s = $lang['Guest_user_total'];
}
else
{
$l_g_user_s = $lang['Guest_users_total'];
}

$l_online_users = sprintf($l_t_user_s, $total_online_users);
$l_online_users .= sprintf($l_r_user_s, $logged_visible_online);
$l_online_users .= sprintf($l_h_user_s, $logged_hidden_online);
$l_online_users .= sprintf($l_g_user_s, $guests_online);
}



"



I guess ill try this now, im doubting it will work
wGEric
Former Team Member
Posts: 8805
Joined: Sun Oct 13, 2002 3:01 am
Location: Friday
Name: Eric Faerber
Contact:

Post by wGEric »

Isn't that code in the page_header.php file? If it is then you just have to put the right varibles in the template file so it will display the information.

If you want the stats of the board (newest user, total posts, so on) then you need to stick this in the php file of the page you want it to show on. You have to do this since it is in index.php of the forum and not page_header.php

Code: Select all

//
// If you don't use these stats on your index you may want to consider
// removing them
//
$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');
$newest_userdata = get_db_stat('newestuser');
$newest_user = $newest_userdata['username'];
$newest_uid = $newest_userdata['user_id'];

if( $total_posts == 0 )
{
	$l_total_post_s = $lang['Posted_articles_zero_total'];
}
else if( $total_posts == 1 )
{
	$l_total_post_s = $lang['Posted_article_total'];
}
else
{
	$l_total_post_s = $lang['Posted_articles_total'];
}

if( $total_users == 0 )
{
	$l_total_user_s = $lang['Registered_users_zero_total'];
}
else if( $total_users == 1 )
{
	$l_total_user_s = $lang['Registered_user_total'];
}
else
{
	$l_total_user_s = $lang['Registered_users_total'];
}

if ( isset($HTTP_POST_VARS['start']) || isset($HTTP_GET_VARS['start']) )
{
    $start = ( isset($HTTP_POST_VARS['start']) ) ? $HTTP_POST_VARS['start'] : $HTTP_GET_VARS['start'];
}
else
{
    $start = '0';
}
Eric
Astaldaran
Registered User
Posts: 41
Joined: Thu Apr 17, 2003 11:01 pm
Contact:

Post by Astaldaran »

Ok thanks, i had that last night just didn't get around to posting.

Anyway so i run it, and it coems up with the following error
(linK: http://www.redemptionohio.com/index2.php )

ERROR: Fatal error: Call to undefined function: get_db_stat() in /home/wesley/public_html/index2.php on line 22

Remember this file is not in the same directory as my boards (my boards are under www.redemptionohio.com/boards or /home/wesley/public_html/boards/ )

I am kind of thinking it is because i need an include, any ideas of which one i need?


ok here is the complete code


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
<meta name="Microsoft Theme" content="artsy 000, default">
<meta name="Microsoft Border" content="tlb, default">
</head>

<body bgcolor="#000000" text="#FFFFCC" link="#FF9900" vlink="#999900" alink="#669933"><!--msnavigation--><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><!--mstheme--><font face="Arial, Helvetica"><p><img src="images/logo.gif"
alt="[Company Logo Image]" border="0" width="120" height="24">
<font size="6" color="#FF0000"><img border="0" src="_borders/redemption_ohio_logo_kings.jpg" width="550" height="286">.com</font> </p>


<?php
//
// If you don't use these stats on your index you may want to consider
// removing them
//
$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');
$newest_userdata = get_db_stat('newestuser');
$newest_user = $newest_userdata['username'];
$newest_uid = $newest_userdata['user_id'];

if( $total_posts == 0 )
{
$l_total_post_s = $lang['Posted_articles_zero_total'];
}
else if( $total_posts == 1 )
{
$l_total_post_s = $lang['Posted_article_total'];
}
else
{
$l_total_post_s = $lang['Posted_articles_total'];
}

if( $total_users == 0 )
{
$l_total_user_s = $lang['Registered_users_zero_total'];
}
else if( $total_users == 1 )
{
$l_total_user_s = $lang['Registered_user_total'];
}
else
{
$l_total_user_s = $lang['Registered_users_total'];
}

if ( isset($HTTP_POST_VARS['start']) || isset($HTTP_GET_VARS['start']) )
{
$start = ( isset($HTTP_POST_VARS['start']) ) ? $HTTP_POST_VARS['start'] : $HTTP_GET_VARS['start'];
}
else
{
$start = '0';
}

?>

<p>

</p>
<p>
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
<tr>
<td class="catHead" colspan="2" height="28"><span class="cattitle"><a href="{U_VIEWONLINE}" class="cattitle">{L_WHO_IS_ONLINE}</a></span></td>
</tr>
<tr>
<td class="row1" align="center" valign="middle" rowspan="2"><img src="boards/templates/subSilver/images/whosonline.gif" alt="{L_WHO_IS_ONLINE}" /></td>
<td class="row1" align="left" width="100%"><span class="gensmall">{TOTAL_POSTS}<br />{TOTAL_USERS}<br />{NEWEST_USER}</span>
</td>
</tr>
<tr>
<td class="row1" align="left"><span class="gensmall">{TOTAL_USERS_ONLINE} & [ {L_WHOSONLINE_ADMIN} ] & [ {L_WHOSONLINE_MOD} ]<br />{RECORD_USERS}<br />{LOGGED_IN_USER_LIST}</span></td>
</tr>
</table>

<table width="100%" cellpadding="1" cellspacing="1" border="0">
<td align="left" valign="top"><span class="gensmall">{L_ONLINE_EXPLAIN}</span></td>
</table>

<br>

</p>


<p>
Our official boards are at& <a href="/boards">http://www.RedemptionOhio.com/boards.htm&</a>
</p>


<p>

</p>


<p><font size="4" color="#FF0000">NEW! </font><font size="2" color="#FF0000">(May
27)</font></p>

<p><font face="Monotype Corsiva" size="5"><a href="kings.jpg">Kings tourney
Announced! &</a> </font></p>

<!--mstheme--></font></td></tr><!--msnavigation--></table><!--msnavigation--><table dir="ltr" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td valign="top" width="1%"><!--mstheme--><font face="Arial, Helvetica">


<p>&</p>


<p>

</p>

<!--mstheme--></font></td><td valign="top" width="24"></td><!--msnavigation--><td valign="top"><!--mstheme--><font face="Arial, Helvetica">

<!--mstheme--></font><!--msnavigation--></td></tr><!--msnavigation--></table><!--msnavigation--><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><!--mstheme--><font face="Arial, Helvetica">

<p><a href="mailto:wesleytamkin@hotmail.com">webmaster@redemptionohio.com</a> or
click <a href="email.htm">here</a></p>



<p>This site is best viewed at 1280 x 1024</p>



<h5><!--mstheme--><font color="#FF9933">

Send mail to <a href="mailto:wesleytamkin@hotmail.com">webmaster@redemptionohio.com</a> with
questions or comments about this web site.<br>


Copyright © 2002- 2003 Redemption Ohio<br>


Last modified: May 30, 2003<!--mstheme--></font></h5>

<!--mstheme--></font></td></tr><!--msnavigation--></table></body>

</html>
wGEric
Former Team Member
Posts: 8805
Joined: Sun Oct 13, 2002 3:01 am
Location: Friday
Name: Eric Faerber
Contact:

Post by wGEric »

Put this right below the <?php

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = './boards/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
Eric
Astaldaran
Registered User
Posts: 41
Joined: Thu Apr 17, 2003 11:01 pm
Contact:

Post by Astaldaran »

Thanks, ok now the error is gone. But it looks like it did before, before i added teh code. it is probably something not right in the template. So im going to look, if you guys notice somethnig wrrong before i do post.
Astaldaran
Registered User
Posts: 41
Joined: Thu Apr 17, 2003 11:01 pm
Contact:

Post by Astaldaran »

oK I know it is the code because i tested it by adding

"
<p>
Total posts <?php echo "$total_posts"; ?>
Total Users <?php echo "$total_users"; ?>

</p>

"
and it worked;


so its the template, whats wrong with it? hmm
Post Reply

Return to “[2.0.x] MOD Writers Discussion”