1 (edited by qqpwn 2009-10-11 12:00)

Topic: Using PunBB style on standalone website

Im planning to use PunBB as core for my website (using PunBB for kind of an CMS).

I already fixed the navigation to show "Forums" instead of "Index", and added custom "Main page" and "About" links. However, I would like to have the same style for both my "Main" and "About" pages and the forum. How would I go to have the PunBB navigation bar, and title on my stand-alone page "about.php"?

I would like to have the same font, link color, size etc. as it's in the forum style, but just that the normally "forum area" below the title and navigation is blank for me to add custom content.

EDIT. Simple example: http://www.aijaa.com/img/b/00619/5045203.png

2 (edited by Parpalak 2009-10-13 08:44)

Re: Using PunBB style on standalone website

Place this code into about.php.

<?php

    define('FORUM_ROOT', './'); // Point to the forum directiry
    define('FORUM_PAGE', 'my-custom-page');
    require FORUM_ROOT.'include/common.php';

    $forum_hooks['hd_main_elements'][] = 'unset($main_elements[\'<!-- forum_crumbs_top -->\']); unset($main_elements[\'<!-- forum_crumbs_end -->\']);';

    require FORUM_ROOT.'header.php';

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

?>
    <div class="main-content" id="custom-content">
        Custom content here
    </div>
<?php

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

    // Uncomment this if you don't want the footer
    //$tpl_main = preg_replace('#<div id="brd-about" class="gen-content">.*?</div>#us', '', $tpl_main);

    require FORUM_ROOT.'footer.php';

And add this to your CSS:

#custom-content {
    margin-top: 1em;
    padding: 1em;
}
 
#custom-content br {
    display: inline;
}

I think you've got the idea.
Enjoy! smile

3

Re: Using PunBB style on standalone website

Parpalak wrote:

Place this code into about.php.

<?php

    define('FORUM_ROOT', './'); // Point to the forum directiry
    define('FORUM_PAGE', 'my-custom-page');
    require FORUM_ROOT.'include/common.php';

    $forum_hooks['hd_main_elements'][] = 'unset($main_elements[\'<!-- forum_crumbs_top -->\']); unset($main_elements[\'<!-- forum_crumbs_end -->\']);';

    require FORUM_ROOT.'header.php';

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

?>
    <div class="main-content" style="margin-top: 1em; padding: 1em;">
        Custom content here
    </div>
<?php

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

    // Uncomment this if you don't want the footer
    //$tpl_main = preg_replace('#<div id="brd-about" class="gen-content">.*?</div>#us', '', $tpl_main);

    require FORUM_ROOT.'footer.php';

I think you've got the idea.
Enjoy! smile

Thanks a lot! That was exactly what I wanted. After few test Ive done, it seems PunBB fits perfectly as an CMS! wink

Re: Using PunBB style on standalone website

You're welcome smile

5 (edited by qqpwn 2009-10-12 14:28)

Re: Using PunBB style on standalone website

I encountered an strange problem when using the code above. My newline doesnt work.

No matter how I do it, it just doesnt switch the line. On forum posts and on other .php pages it does work, but when using the code above to create layout it doesnt work.

Examples that doesnt work:

<?php echo "Hello"; ?> <br />
<?php echo "World"; ?> <br />

Outputs: "Hello World"

Hello <br /> World <br />

Outputs: "Hello World"

<?php echo "Hello \n World"; ?>

Outputs: "Hello World"

and so on... What disables my newline?

Re: Using PunBB style on standalone website

It doesn't work because '<BR>' is disabled in CSS. You can enable it explicitly for your content. You'll find how to do this in my previous post (I've edited it).

7

Re: Using PunBB style on standalone website

Thanks! smile