Seite 1 von 1

Custom Page

Verfasst: 08.04.2012 12:03
von comiplo
Guten Tag.

Ich versuche gerade eine Custom-Page bei phpBB zu machen, die leider alles andere als funktioniert.

Der PHPBB_ROOT_PATH ist http://localhost/ein_ordner/forum - somit sieht der Kopf meiner *.php-Datei so aus:

http://localhost/ein_ordner/forum/file.php

Code: Alles auswählen

<?php

global $phpbb_root_path;
global $phpEx;
global $user;
global $auth;

// Specify the path to your phpBB3 installation directory.
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : '/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
// The common.php file is required.
include($phpbb_root_path . 'common.' . $phpEx);

// since we are grabbing the user avatar, the function is inside the functions_display.php file since RC7
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
Später versuche ich auf das Template zuzugreifen:

Code: Alles auswählen

$template->assign_vars(array(
	'CUSTOMPAGE_USERNAME' => "Username-Test",
));
$template->set_filenames(array(
	'body' => 'template.html',
));
page_footer();
?>
Rufe ich diese Seite im Browser auf, bekomme ich zwar keinen Fehler, aber auch nur eine weiße Seite. Das Template befindet sich in http://localhost/ein_ordner/forum/styles/subsilver2/template/template.html

Was mache ich falsch?

MfG und Frohe Ostern

Re: Custom Page

Verfasst: 08.04.2012 12:50
von Helmut
Hallo comiplo,

den Teil kannst du weg lassen, wird in der Form nicht gebraucht:

Code: Alles auswählen

global $phpbb_root_path;
global $phpEx;
global $user;
global $auth;
 
Hier mal die richtige Reihenfolge:

Code: Alles auswählen

<?php

define('IN_PHPBB', true);
// Specify the path to you phpBB3 installation directory.
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; //Wenn sich diese Datei im root Verzeichnis befindet wo auch die config.php ist
$phpEx = substr(strrchr(__FILE__, '.'), 1);
// The common.php file is required.
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);

$user->setup('mods/my_language_file'); //Für deine Sprachdatei falls du eine angelegt hast


//your PHP and/or HTML code goes here

$template->assign_vars(array(
   'CUSTOMPAGE_USERNAME' => "Username-Test",
));
$template->set_filenames(array(
   'body' => 'template.html',
));
page_footer();

?>
Du solltest dir auch mal das Tutorial.Adding pages anschauen, da ist ein Beispiel wie eingebundene Seiten aufgebaut sind. Wenn du Sprachdateien selber erstellst, dann achte darauf dass du diese in UTF-8 ohne BOM abspeicherst, sonst kommt gerne eine weiße Seite. Übrigens der Editor von Windows ist dafür nicht geeignet, besser du nimmst den Notepad++ oder auch den SciTE.

Gruß Helmut

Re: Custom Page

Verfasst: 08.04.2012 12:50
von gloriosa
Hallo,
die >>> Vorlage für in phpBB eingebundene Seiten in phpBB3 <<< kennst Du schon ? :o

Re: Custom Page

Verfasst: 08.04.2012 13:18
von comiplo
Danke, @beide.

@Helmut
Damit das Script richtig funktioniert, fehlt noch page_header("Überschrift");.

@gloriosa
Nein, kannte ich nicht, Danke. :)

Re: Custom Page

Verfasst: 08.04.2012 13:27
von Helmut
Hallo comiplo,

stimmt, hatte ich übersehen dass du das page_headre (); in deinem Code nicht drinnen hattest.

Gruß Helmut