phpbb templating system problems

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.
Post Reply
User avatar
Dalgar
Registered User
Posts: 93
Joined: Mon May 27, 2002 2:09 am
Location: Minnesota
Contact:

phpbb templating system problems

Post by Dalgar »

Hi. I posted about this general problem a while back, but I have another question relating to it.

Code: Select all

switch ($_GET['p']) 
{ 
    case 'humans': 
        $include = 'http://dbknights.amzweb.net/wow/information/races/humans.php'; 
        break; 

    default: 
        $include = 'news.tpl'; 
        break; 
} 

$content = implode('', file($include)); 

$template->assign_vars(array( 
      'CONTENT' => $content));
That code is more or less in a stripped down ezPortal page that just uses phpBB sessions and page headers. My portal_body.tpl page has {CONTENT} in it, which is where the news.tpl goes.

However, my problem is that news.tpl isn't getting {L_POSTED} etc, taken out of it. I assume (if I understand how it works :oops: ) that the php script skips it, because it already did that line when it removed the {CONTENT} tag. Is there a way I could get it to go over this piece again?

Hope I was clear on my problem :(
The Early Bird May Get The Worm But The Second Mouse Gets The Cheese.
User avatar
morpheus2matrix
Former Team Member
Posts: 9171
Joined: Wed Apr 10, 2002 7:31 pm
Location: France
Contact:

Post by morpheus2matrix »

a such post should be in the MOD-Author Forum next time :wink:


For your problem, can you explain what you want to do exactly ?
Former phpBB MOD-Team Member -

Forgive my bad English :(

No support by PM/Email - Thanks - You can thanks me here :) - Pay me for installing MOD's :lol:
netclectic
Former Team Member
Posts: 4439
Joined: Wed Mar 13, 2002 3:08 pm
Location: Omnipresent
Contact:

Post by netclectic »

Ok, i've moved this into the MOD Authors Support Forum.

I think you're maybe going about it the wrong way. As morpheus said, can you explain what you want to achieve in more detail and we'll hopefully be able to help you out.
Defend the game:
Image
User avatar
Dalgar
Registered User
Posts: 93
Joined: Mon May 27, 2002 2:09 am
Location: Minnesota
Contact:

Post by Dalgar »

Yes, that may be that I'm going about it the wrong way. Like I said, I got help on this here before, and this was the only solution that people could come up with.

What I have, is a portal_body.tpl page that has my left and right columns to my site. Then for the center part, I have a {CONTENT} tag which is supposed to bring in whatever page is called for in the url. EX: http://www.mysite.com/index.php?p=contact

The method I have was the only way that was figured out to be able to "include" a page, and still keep the phpBB templating system in place. Just using include() in index.php inserts my CONTENT page above page_header.tpl for some reason, so that doesn't work.

Did that help?
The Early Bird May Get The Worm But The Second Mouse Gets The Cheese.
netclectic
Former Team Member
Posts: 4439
Joined: Wed Mar 13, 2002 3:08 pm
Location: Omnipresent
Contact:

Re: phpbb templating system problems

Post by netclectic »

You could try this and see if it helps...

Code: Select all

$include = '';

switch ($_GET['p']) 
{ 
    case 'humans': 
        $include = 'http://dbknights.amzweb.net/wow/information/races/humans.php'; 
        break; 

    default: 
        $template->set_filenames(array('news' => 'news.tpl')); 
        $template->assign_var_from_handle('CONTENT', 'news');
        break; 
} 

if ($include != '')
{
$content = implode('', file($include)); 

$template->assign_vars(array( 
      'CONTENT' => $content));
}

i assume there is a $template->pparse somewhere further down the file?
I hanve't tested this so i wouldn't be surprised if it doesn't work at all.


[edit] i forgot a bit... there try that.
Defend the game:
Image
User avatar
Dalgar
Registered User
Posts: 93
Joined: Mon May 27, 2002 2:09 am
Location: Minnesota
Contact:

Post by Dalgar »

Well, the good news: No errors :o (er, maybe thats bad? :? )
http://dbknights.amzweb.net/wow/index.php

The bad news: It doesn't work.

It is removing the {CONTENT} tag, and putting nothing back in its place.

My index.php file is below. (if it helps) The section of code we have been talking about is about half way down, right above the assigning variables, and right below the avatar on index mod. Like I said, its just a ezportal page, modified a bit.

Code: Select all

<?php
/***************************************************************************
 *                                portal.php
 *                            -------------------
 *   begin                : Tuesday, August 13, 2002
 *   copyright            : (C) 2002 Smartor
 *   email                : smartor_xp@       .   
 *
 *   $Id: portal.php,v 2.1.0 2002/9/27, 23:07:35 Smartor Exp $
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   Some code in this file I borrowed from the original index.php, Welcome
 *   Avatar MOD and others...
 *
 ***************************************************************************/

//
// Set configuration for ezPortal
//

// Welcome Text: note that we are in PHP file, so use \' instead of ' and use \\ instead of \ (HTML enabled)
$CFG['welcome_text'] = 'Welcome to our<b> World of Warcraft Site! </b><br /><br />Thanks for visiting us ^_^';

// Number of news on portal
$CFG['number_of_news'] = '5';

// Length of news
$CFG['news_length'] = '600';

// News Forum ID: separate by comma for multi-forums, eg. '1,2,5'
$CFG['news_forum'] = '14';

// Poll Forum ID: separate by comma for multi-forums, eg. '3,8,14'
$CFG['poll_forum'] = '15';

//
// END configuration
// --------------------------------------------------------

define('IN_PHPBB', true);
$phpbb_root_path = '../forums/';
$phpbb_script_path = '../forums';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'fetchposts.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//

//
// 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');
$total_topics = get_db_stat('topiccount');
$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'];
}

//
// Start output of page
//
$page_title = $lang['Home'];
//line 100
include($phpbb_root_path . 'includes/portal_page_header.'.$phpEx);

$template->set_filenames(array(
	'body' => 'portal/portal_body.tpl')
);

//
// Avatar On Index MOD
//
$avatar_img = '';
if ( $userdata['user_avatar_type'] && $userdata['user_allowavatar'] )
{
	switch( $userdata['user_avatar_type'] )
	{
		case USER_AVATAR_UPLOAD:
			$avatar_img = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $userdata['user_avatar'] . '" alt="" border="0" />' : '';
			break;
		case USER_AVATAR_REMOTE:
			$avatar_img = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $userdata['user_avatar'] . '" alt="" border="0" />' : '';
			break;
		case USER_AVATAR_GALLERY:
			$avatar_img = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $userdata['user_avatar'] . '" alt="" border="0" />' : '';
			break;
	}
}
// Check For Anonymous User
if ($userdata['user_id'] != '-1')
{
	$name_link = '<a href="' . append_sid("$phpbb_script_path/profile.$phpEx?mode=editprofile&" . $userdata['user_id']) . '">' . $userdata['username'] . '</a>';
	
}
else
{
	$name_link = $lang['Guest'];
}
//
// END: Avatar On Index MOD
//

$include = ''; 

switch ($_GET['p']) 
{ 
    case 'humans': 
        $include = 'http://dbknights.amzweb.net/wow/information/races/humans.php'; 
        break; 

    default: 
        $template->set_filenames(array('news' => 'news.tpl')); 
        $template->assign_var_from_handle('CONTENT', 'news'); 
        break; 
} 

if ($include != '') 
{ 
$content = implode('', file($include)); 

$template->assign_vars(array( 
      'CONTENT' => $content));
}

$template->assign_vars(array(
	'WELCOME_TEXT' => $CFG['welcome_text'],
	'TOTAL_POSTS' => sprintf($l_total_post_s, $total_posts),
	'TOTAL_USERS' => sprintf($l_total_user_s, $total_users),
	'TOTAL_TOPICS' => sprintf($lang['total_topics'], $total_topics),
	'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="' . append_sid("$phpbb_script_path/profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$newest_uid") . '">', $newest_user, '</a>'),
	'L_FORUM' => $lang['Forum'],
	'L_BOARD_NAVIGATION' => $lang['Board_navigation'],
	'L_STATISTICS' => $lang['Statistics'],	
	'L_ANNOUNCEMENT' => $lang['Post_Announcement'],
	'L_POSTED' => $lang['Posted'],
	'L_COMMENTS' => $lang['Comments'],
	'L_VIEW_COMMENTS' => $lang['View_comments'],
	'L_POST_COMMENT' => $lang['Post_your_comment'],
	'L_SEND_PASSWORD' => $lang['Forgotten_password'],
	'U_SEND_PASSWORD' => append_sid("$phpbb_script_path/profile.$phpEx?mode=sendpassword"),
	'L_REGISTER_NEW_ACCOUNT' => sprintf($lang['Register_new_account'], '<a href="' . append_sid("$phpbb_script_path/profile.$phpEx?mode=register") . '">', '</a>'),
	'L_REMEMBER_ME' => $lang['Remember_me'],
	'L_VIEW_COMPLETE_LIST' => $lang['View_complete_list'],
	'L_POLL' => $lang['Poll'],
	'L_VOTE_BUTTON' => $lang['Vote'],

	// Welcome Avatar
	'L_NAME_WELCOME' => $lang['Welcome'],
	'U_NAME_LINK' => $name_link,
	'AVATAR_IMG' => $avatar_img)
);

//
// Fetch Posts from Announcements Forum
//
if(!isset($HTTP_GET_VARS['article']))
{
	$template->assign_block_vars('welcome_text', array());

	$fetchposts = phpbb_fetch_posts($CFG['news_forum'], $CFG['number_of_news'], $CFG['news_length']);

	for ($i = 0; $i < count($fetchposts); $i++)
	{
		$template->assign_block_vars('fetchpost_row', array(
			'TITLE' => $fetchposts[$i]['topic_title'],
			'POSTER' => $fetchposts[$i]['username'],
			'TIME' => $fetchposts[$i]['topic_time'],
			'TEXT' => $fetchposts[$i]['post_text'],
			'REPLIES' => $fetchposts[$i]['topic_replies'],
			'U_VIEW_COMMENTS' => append_sid('' . $phpbb_script_path . '/viewtopic.' . $phpEx . '?t=' . $fetchposts[$i]['topic_id']),
			'U_POST_COMMENT' => append_sid('' . $phpbb_script_path . '/posting.' . $phpEx . '?mode=reply&t=' . $fetchposts[$i]['topic_id']),
			'U_READ_FULL' => append_sid('' . $phpbb_script_path . '/portal.' . $phpEx . '?article=' . $i),
			'L_READ_FULL' => $lang['Read_Full'],
			'OPEN' => '[ ',
			'CLOSE' => ' ]'
			)
		);
	}
}
else
{
	$fetchposts = phpbb_fetch_posts($CFG['news_forum'], $CFG['number_of_news'], 0);

	$i = intval($HTTP_GET_VARS['article']);

	$template->assign_block_vars('fetchpost_row', array(
		'TITLE' => $fetchposts[$i]['topic_title'],
		'POSTER' => $fetchposts[$i]['username'],
		'TIME' => $fetchposts[$i]['topic_time'],
		'TEXT' => $fetchposts[$i]['post_text'],
		'REPLIES' => $fetchposts[$i]['topic_replies'],
		'U_VIEW_COMMENTS' => append_sid('$phpbb_script_path' . '/viewtopic.' . $phpEx . '?t=' . $fetchposts[$i]['topic_id']),
		'U_POST_COMMENT' => append_sid('$phpbb_script_path/posting.' . $phpEx . '?mode=reply&t=' . $fetchposts[$i]['topic_id'])
		)
	);
}
//
// END: Fetch Announcements
//


//
// Fetch Poll
//
$fetchpoll = phpbb_fetch_poll($CFG['poll_forum']);

if (!empty($fetchpoll))
{
	$template->assign_vars(array(		
		'S_POLL_QUESTION' => $fetchpoll['vote_text'],
		'S_POLL_ACTION' => append_sid($phpbb_script_path.'/posting.'.$phpEx.'?'.POST_TOPIC_URL.'='.$fetchpoll['topic_id']),
		'S_TOPIC_ID' => $fetchpoll['topic_id'],
		'L_SUBMIT_VOTE' => $lang['Submit_vote'],
		'L_LOGIN_TO_VOTE' => $lang['Login_to_vote']		
		)
	);

	for ($i = 0; $i < count($fetchpoll['options']); $i++)
	{
		$template->assign_block_vars('poll_option_row', array(
			'OPTION_ID' => $fetchpoll['options'][$i]['vote_option_id'],
			'OPTION_TEXT' => $fetchpoll['options'][$i]['vote_option_text'],
			'VOTE_RESULT' => $fetchpoll['options'][$i]['vote_result'],
			)
		);
	}	
}
else
{
	$template->assign_vars(array(		
		'S_POLL_QUESTION' => $lang['No_poll'],
		'DISABLED' => 'disabled="disabled"'
		)
	);
}

//
// Generate the page
//
$template->pparse('body');



?>
and the news.tpl file:

Code: Select all

<!-- BEGIN fetchpost_row -->
		<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
		  <tr>
			<td class="catHead" height="25"><b><center>{fetchpost_row.TITLE}</center></b></td>
		  </tr>
		  <tr>
			<td class="row2" align="left" height="24"><span class="gensmall">{L_POSTED}: <b>{fetchpost_row.POSTER}</b> @ {fetchpost_row.TIME}</span></td>
		  </tr>
		  <tr>
			<td class="row1" align="left"><span class="gensmall" style="line-height:150%">{fetchpost_row.TEXT}<br /><br />{fetchpost_row.OPEN}<a href="{fetchpost_row.U_READ_FULL}">{fetchpost_row.L_READ_FULL}</a>{fetchpost_row.CLOSE}</span></td>
		  </tr>
		  <tr>
			<td class="row3" align="left" height="24"><span class="gensmall">{L_COMMENTS}: {fetchpost_row.REPLIES} :: <a href="../../../phpBB2/{fetchpost_row.U_VIEW_COMMENTS}">{L_VIEW_COMMENTS}</a> (<a href="../../../phpBB2/{fetchpost_row.U_POST_COMMENT}">{L_POST_COMMENT}</a>)</span></td>
		  </tr>
		</table>
		
		<br />

		<!-- END fetch_post_row -->
Thanks for the help.
The Early Bird May Get The Worm But The Second Mouse Gets The Cheese.
User avatar
Wooly Spud
Registered User
Posts: 166
Joined: Tue Jun 11, 2002 11:18 am

Post by Wooly Spud »

Ok i just saw this and wanted to enter my 2 cents.

You MUST have all variables that will be used in the called template for {CONTENT} assigned before you call the assign_var_from_handle function.

Hers an example from my site.

Code: Select all

//
// Body
//

// Set template Filename
$xgstyle->set_filenames(array(
		'body' => 'index_body.tpl',
		'content' => 'test.tpl')
	);


//
// Content Inner Template Code Block
//

// Assign all veriables for Content handler.

$xgstyle->assign_vars(array(
		'NAME' => 'Splinter Cell for Game Cube Announced..',
		'BODY' => 'Sweet!',
));

// Call innner template and compile its content.
$xgstyle->assign_var_from_handle('CONTENT', 'content');
as you can see i declared the handle in the beginning of my code then started declaring variables to be used for the internal template and then i declared assign var from handle.

try and rearange the code this way and see if it works :)
User avatar
Dalgar
Registered User
Posts: 93
Joined: Mon May 27, 2002 2:09 am
Location: Minnesota
Contact:

Post by Dalgar »

Hey thanks, that might be useful in a new thing I'm working on :) To be honest with you, I kind of changed direction a bit with this. I split my portal_body.tpl up into 2 template files (left and right) and then I was able to just use include() to bring in my content page. It works, which is all I care about :P

Whats your site? I'm curious to see what you've done with phpbb.
The Early Bird May Get The Worm But The Second Mouse Gets The Cheese.
User avatar
Wooly Spud
Registered User
Posts: 166
Joined: Tue Jun 11, 2002 11:18 am

Post by Wooly Spud »

Well my site is ww.xgmag.com but i have not actualy setup a section devoted to my phpbb mods yet. I kindaa have been trying to get my site DB system setup so i can open the site. However you might be intrested in looking at my boards (i have not finished setting them up yet but i have test forums up to test my mods)

The current mods installed that i have made are 'Advanced Banned User Manager', 'Registration Information Confirmation', and 'phpAdd Pro'

Add pro is incomplete because im going to expand it so you can limit the number of appearances of a particular banner, Customer accounts so you can manage ads by customer (customer referes to the person you are advertising for) and other things.

Also i have a swgPA site that uses my ChatBox v3.0 on its boards if you are intrested in seeing that. I have done more phpbb stuff with that sites boards system such as pages accessable to certain usergroups I did this for my memberlist and usergroups pages. the main site for it also uses a modified version of fetch posts.

That site is www.xgmag.com/swg-bds and www.xgmag.com/swg-bds/boards

im also always looking for a good chalenge in making a mod. i keep an eye out for the KMR's.

In anycase check the sites out and feel free to drop me a pm or email sometime.
User avatar
piertiong
Registered User
Posts: 66
Joined: Sat Jun 07, 2003 12:36 pm

Post by piertiong »

hi there, how do you include a page in a php page and assign a name(eg content) to it so that i can use {CONTENT} in the .tpl page?

thanks.
Post Reply

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