Hallo efrick,
du willst also den Wert {ANZAHL} auf allen Seiten angezeigt bekommen, habe ich das richtig verstanden?
Wenn ja, dann ist es ganz einfach, du gehts so vor:
Öffne die includes/functions.php und finde folgendes:
Code: Alles auswählen
// The following assigns all _common_ variables that may be used at any point in a template.
$template->assign_vars(array(
und füge davor deinen Code ein:
Code: Alles auswählen
// Dein Code
$sql = 'SELECT count(*) AS anzahl
FROM' . USERS_TABLE . '
WHERE group_id IN (1,2,3,4,5)';
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
//--------------------------
finde folgendes:
Code: Alles auswählen
// The following assigns all _common_ variables that may be used at any point in a template.
$template->assign_vars(array(
und füge danach ein:
Jetzt kannst du
{ANZAHL}
an beliebiger Stelle in deinem Forum einbauen, muss nicht zwinfgend die overall_header.html sein und du hast den Wert immer da.
Wenn du einen längeren Code machst, dann würde ich den Code in eine eigene z.B. includes/functions_deinedatei.php auslagern und mit
include($phpbb_root_path . 'includes/functions_deinedatei.' . $phpEx);
vor
// The following assigns all _common_ variables that may be used at any point in a template.
einbinden.
Deine includes/functions_deinedatei.php würde dann so aussehen:
Code: Alles auswählen
<?php
/**
*
* @author Original Author
*
*
* @package svi
* @version $Id: functions_deinedatei.php,v 0.0.1 2012/01/19 Exp $
* @copyright (c) 2012 .....
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
die('Hacking Attempt!');
}
//Ab hier dein Code
$sql = 'SELECT count(*) AS anzahl
FROM' . USERS_TABLE . '
WHERE group_id IN (1,2,3,4,5)';
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
//Ausgabe
$template->assign_vars(array(
'ANZAHL' => $row['anzahl'],
));
?>
Eine eigene php Datei ist nur interessant wenn du z.B. eine zusätzliche Seite in dein Forum einbauen willst wie etwa ein Impressum, der Code recht lang ist oder du den Code nur für bestimmte Seiten brauchst.
Gruß Helmut
Ich bin nicht ganz dicht.... na und.