1 (edited by Meteolab 2008-12-26 20:38)

Topic: How to add some HTML into forum?

Hello,

with punbb 1.2.x it was simple to embed HTML into the forum, I changed the index.php to a renamed php-file:

<?php

define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';

if ($pun_user['is_guest'] && $pun_user['g_read_board'] == '1')
        message($lang_common['No permission']);
// Load the userlist.php language file
// Load the index.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/userlist.php';
// Load the online.php language file
require PUN_ROOT.'lang/English/online.php';

$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_online['Online List'];

define('PUN_ALLOW_INDEX', 1);

require PUN_ROOT.'header.php';


?>
<div>

MY HTML TEXT IS HERE

</div>

<?php

$footer_style = 'index';
require PUN_ROOT.'footer.php';
?>

But with punbb 1.3.x I have no idea to get the same result. My HTML-Code starts in the output always before the punbb-heading. Now it follows my implementation that looks so far:

<?php
/**
 * Displays a list of the categories/forums that the current user can see, along with some statistics.
 *
 * @copyright Copyright (C) 2008 PunBB, partially based on code copyright (C) 2008 FluxBB.org
 * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
 * @package PunBB
 */


if (!defined('FORUM_ROOT'))
    define('FORUM_ROOT', './');
require FORUM_ROOT.'include/common.php';

($hook = get_hook('in_start')) ? eval($hook) : null;

if ($forum_user['g_read_board'] == '0')
    message($lang_common['No view']);

// Load the index.php language file
require FORUM_ROOT.'lang/'.$forum_user['language'].'/index.php';


// Setup main heading
$forum_page['main_title'] = forum_htmlencode($forum_config['o_board_title']);

($hook = get_hook('in_pre_header_load')) ? eval($hook) : null;

define('FORUM_ALLOW_INDEX', 1);
define('FORUM_PAGE', 'index');
require FORUM_ROOT.'header.php';
?>

<p>My HTML</p>

<?php
// END SUBST - <!-- forum_info -->

require FORUM_ROOT.'footer.php';
?>

Re: How to add some HTML into forum?

I've found this info:

Is it possible to include my own PHP scripts in the templates?

Yes. PunBB has a special replacement variable called pun_include for including scripts in the templates. For example, if you wanted to include a script called banner.php at the bottom of all forum pages, you would place the script in include/user/ and add the following to your template files:

    <pun_include "banner.php">

    The script banner.php must be located in the user include directory mentioned above and its file extension must be .php, .php4, .php5, .inc, .htm, .html or .txt. PunBB will execute the script and the pun_include variable will be replaced by any output that the script produces. Please note that all included scripts have access to the PunBB variables, so if you e.g. wanted to access the database, you could use the $db object just like the rest of PunBB does. Be careful when dealing with global variables in included scripts so that they don't collide with PunBB's global variables.

Source: http://punbb.informer.com/docs/faq.html#faq3_3

Greetings,
Meteolab

Re: How to add some HTML into forum?

That's for v1.2, what about 1.3?

Re: How to add some HTML into forum?

ok, I worked a few and now I have managed my problem, here is my solution:

(weathercams.html is my wanted HTML-File)

if (!defined('FORUM_ROOT'))
    define('FORUM_ROOT', './');
require FORUM_ROOT.'include/common.php';

($hook = get_hook('in_start')) ? eval($hook) : null;

//only members are allowed to view 

if (!$forum_user['is_guest'] == '0')
{
    message($lang_common['No permission']);
    exit;
}

$page_title = forum_htmlencode($forum_config['o_board_title']);
define('FORUM_PAGE', 'weathercams');
require FORUM_ROOT.'header.php';

// START SUBST - <!-- forum_main -->
ob_start();

require FORUM_ROOT.'weathercams.html';

$tpl_temp = forum_trim(ob_get_contents());
$tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main);
ob_end_clean();
// END SUBST - <!-- forum_main -->

require FORUM_ROOT.'footer.php';
?>

I think some obsolete code is also included so far but this little hack works

Greetings,
Meteolab

Re: How to add some HTML into forum?

Strofanto wrote:

That's for v1.2, what about 1.3?

to include a file in 1.3 you use <!-- forum_include "FILE" --!> .

Sorry. Unactive due to personal life.

Re: How to add some HTML into forum?

Thanks Utchin.

Re: How to add some HTML into forum?

It worked like this:
<!-- forum_include "FILE" -->
thanks

http://tinymailto.com/oliversl <-- my email after a captcha