Custom block, how to :).

Current Version: 1.0.6
Released: 09.01.10
Forum rules
Before creating a new support thread, please take a look in the board3 Portal FAQ and use the search!
Many questions have already been answered.
Locked

Topic author
Tryskell
Active Member
Posts: 4
Joined: 25. January 2010 03:04

Custom block, how to :).

Post by Tryskell »

Your Portal Version: the one in attachment on your portal ;o
Your phpBB Type: Standard phpBB3
MODs installed: Nope
Your knowledge: Ultra-Beginner in forum related things

Description and Message
Hiho, I try to adapt an easy block which must show a server status, number of online players, and max players. It's made for GF portal, but as it's dead, and your is fine, I try edit the block :P.

I followed the tutorial to create the new bloc, and I can succesfully add things inside.

Problem is I don't get how the hell it's supposed to work. And there is no tutorial post-block creation ;o.

I have understood :

- you must create an html to "format" datas you want to show, and a php located in portal/block/.
- {L_VARIABLE] is supposed to show variable on html, but it shows {VARIABLE} inboard. In the PHP, I have found variables were all down, in an array.

And that's all lol. I tried to check existing blocks (the leader one, I thought it was simple), but I just don't get it how the link between the PHP and the HTML is done without using the ACP (aka admin panel/mods).

If you can point me on existing tuto I didn't see, or even an existing case... I read 10-15 topics about custom block, but it doesn't talk of creation.

I post code of what I tried to make, if you need original code ask, I will post.

PHP side (near not edited) :

Code: Select all

<?php
/**
 *
 * Mod:		Server Status Bloc
 * Auteur:	Psychokiller1888 (http://www.l2-semper-fidelis.com / http://www.team-masters-of-war.com)
 * Notes:	Oui, c'est completement gratuit, vous pouvez tout changer si vous le voulez, sans me demander quoi que ce soit
 * 			mais s'il vous plait, soyez assez sympa et gardez au moin un trace de moi!
 *
 * Version:	1.1.0
 * Date:	29.06.08
 *
 * Version History
 * 1.1.0 Modif sur record en ligne
 *
 */

if (!defined('IN_PHPBB') || !defined('IN_PORTAL'))
{
   exit;
}

include ("./config_l2server.php");

$serverhost = $dbhost;

//Game server
$check = @fsockopen ($serverhost, 7777, $errno, $errstr, 1.0);
if (!$check)
{
	$servers['game_server'] = "<img src=\"/images/offline.gif\" width=\"14\" height=\"14\" title=\"Offline\" alt=\"Offline\"> Offline";
}
else
{
	$servers['game_server'] = "<img src=\"/images/online.gif\" width=\"14\" height=\"14\" title=\"Online\" alt=\"Online\"> Online";
	$gs_online = TRUE;
}
@fclose($$check);

//Login Server
$check = @fsockopen ($serverhost, 2106, $errno, $errstr, 1.0);
if (!$check)
{
	$servers['login_server'] = "<img src=\"/images/offline.gif\" width=\"14\" height=\"14\" title=\"Offline\" alt=\"Offline\"> Offline";
}
else
{
	$servers['login_server'] = "<img src=\"/images/online.gif\" width=\"14\" height=\"14\" title=\"Online\" alt=\"Online\"> Online";
	$ls_online = TRUE;
}
@fclose($check);

//On recherche le nombre de joueurs, mais seulement si le game server est en ligne

$nbr_player = 0;
$max_players = "";
$date = "";

if ($gs_online)
{
	$connect = @mysql_connect ("$dbhost", "$dbusername", "$dbuserpw");
	@mysql_select_db( "$dbname", $connect );

	$sql = "select online from characters where online = '1'";
	if (!$result = mysql_query($sql))
	{
		die('Impossible de retourner les joueurs en ligne!');
	}
	$nbr_player = mysql_num_rows($result);

	$multiple = ($nbr_player < 2) ? "" : "s";

	//On recherche le record absolu de joueurs en ligne

	$req_sql = "select * from record ORDER BY maxplayer DESC LIMIT 1";
	$sql = mysql_query($req_sql);

	$line = mysql_fetch_array($sql);

	$max_players = $line['maxplayer']." joueurs en ligne";
	$date = $line['date'];

	$date_explode = explode("-", $date);

	$year = $date_explode[0];
	$month = $date_explode[1];
	$day = $date_explode[2];

	$date = $day."-".$month."-".$year;
}

$template->assign_vars(array(
	'L_GS' => "Game Server : ",
	'L_LS' => "Login Server : ",
	'L_PLAYERS' => $multiple." players online",
	'L_RECORD' => "Record : ",
	'GAME_SERVER' => $servers['game_server'],
	'LOGIN_SERVER' => $servers['login_server'],
	'MAX_PLAYERS' => $max_players,
	'DATE' => "Le ".$date,
	'PLAYERS' => $nbr_player)
);

mysql_close;

$modvar = $template->pparse_mod('body');

?>
HTML side (totally edit, it was on a table...) :

Code: Select all

    {$LR_BLOCK_H_L}SERVERS STATUS{$LR_BLOCK_H_R}
                 <div>
					<b>{L_GS}</b>{GAME_SERVER}<br />
					<b>{L_LS}</b>{LOGIN_SERVER}<br />
					<br /><br />
					{L_PLAYERS}{PLAYERS}<br />
					{L_RECORD}{MAX_PLAYERS}<br>{DATE}
				</div>
        {$LR_BLOCK_F_L}{$LR_BLOCK_F_R} 
I thought variables could be on database, but I didn't found leaders.php ones, so I forget this pist.

I could ask to the author too, but he still uses GF portal, so I don't think he could be helpful :/.
[/i]
User avatar

Mike
Former Team Member
Posts: 1862
Joined: 3. July 2008 23:59
Location: Schwarzwald / FDS
Contact:

Re: Custom block, how to :).

Post by Mike »

You can add your code into a new block.php and include it into portal.php, or just put your php code into portal/block/additional_block.php...
kein Support per PN / Messenger
no Support via PM / Messenger

Topic author
Tryskell
Active Member
Posts: 4
Joined: 25. January 2010 03:04

Re: Custom block, how to :).

Post by Tryskell »

Hi back,

I'm surprised by your answer, my post is enough big (perhaps too much lol) to don't miss infos. I quote myself :
I followed the tutorial to create the new bloc, and I can succesfully add things inside.
So I need help AFTER making the bloc. Making a bloc is easy, it's to implement things inside . My code doesn't work, I see variables names instead see variable values. I don't get how works the block system in fact.

There is a php and a html for each block, so how they are "linked" between them ?
User avatar

Mike
Former Team Member
Posts: 1862
Joined: 3. July 2008 23:59
Location: Schwarzwald / FDS
Contact:

Re: Custom block, how to :).

Post by Mike »

Thats what i mean... Do you already include the php file into portal.php, or did you put the php code into additional_blocks.php? (i would prefer the second)
kein Support per PN / Messenger
no Support via PM / Messenger

Topic author
Tryskell
Active Member
Posts: 4
Joined: 25. January 2010 03:04

Re: Custom block, how to :).

Post by Tryskell »

As I use the last release, I didn't have to use old method described. So I used new one. I use revolution template, which used prosilver template. Except this custom block, all is working fine.

Code of "additional_blocks_right"

Code: Select all

<!-- version $Id: additional_blocks_right.html 503 2009-04-20 18:34:29Z kevin74 $ //-->
<!-- additional_blocks //-->
<!-- INCLUDE portal/block/mod_server_status.html -->
Result Inboard :
http://img641.imageshack.us/img641/5787/sanstitreyg.jpg

And you got the code of Html used and php used in last posts :).

I must check if the different tables used in the php are existing too. Perhaps it comes from that too.
User avatar

Mike
Former Team Member
Posts: 1862
Joined: 3. July 2008 23:59
Location: Schwarzwald / FDS
Contact:

Re: Custom block, how to :).

Post by Mike »

I think we talk at cross-purposes. I know where you put you html code, but what i want to know is, where you put in your php code ;)
kein Support per PN / Messenger
no Support via PM / Messenger

Topic author
Tryskell
Active Member
Posts: 4
Joined: 25. January 2010 03:04

Re: Custom block, how to :).

Post by Tryskell »

Haha, I think too.

I put the php file in the "portal/block/" folder.
The html is in "styles\prosilver\template\portal\block" folder, same folder than "additional_blocks_right.html"

Both got same name, if it's have a clue, mod_server_status.php/html

I saw all php blocks were here so I thought it was fine to put here.

If I didn't understand what you asked, please consider write a tutorial/how to :D.

Because I'm end of my logical possibility with this damn block lol :D.
User avatar

Mike
Former Team Member
Posts: 1862
Joined: 3. July 2008 23:59
Location: Schwarzwald / FDS
Contact:

Re: Custom block, how to :).

Post by Mike »

If you put your php code in a new file, (as it seems) you have to include this file into portal.php, or at least in aditional_block.php...
If not, your portal dont know about this file ;)

Open portal.php and you will see what i mean. I would recomment you to put the following line into aditional_blocks.php:

Code: Select all

		include($phpbb_root_path . 'portal/block/mod_server_status.' . $phpEx);
kein Support per PN / Messenger
no Support via PM / Messenger
Locked

Return to “board3 Portal 1.0.x - English Support”