Page 1 of 1

PhpBB Knowledge Base Mod on board3 Portal

Posted: 23. July 2010 14:42
by t90
PhpBB Knowledge Base Mod block on board3 Portal

Hi there,

I have written a simple block, that accuires article titles from PhpBB Knowledge Base Mod.

Board3 Portal v. 1.0.5
PhpBB Knowledge Base Mod v. 1.0.2RC3

Demo: http://busomania.pl/ (find block titled "Baza wiedzy") on left side column.

Files to be copied:
./root/portal/block/articles.php
./root/styles/prosilver/template/portal/block/articles.html

Files to be edited:
./root/portal.php
./root/styles/prosilver/template/portal/portal_left.html

EDITS:

Open: ./root/portal.php
Find:

Code: Select all

if($portal_config['portal_left_column'])
{
    $template->assign_var('S_LEFT_COLUMN', true); 
Add on a new blank line after preceding lines to find:

Code: Select all

    
    include($phpbb_root_path . 'portal/block/articles.' . $phpEx);
     
Open: ./root/styles/prosilver/template/portal/portal_left.html
Find:

Code: Select all

<!-- IF S_DISPLAY_MAINMENU -->
    <!-- INCLUDE portal/block/main_menu.html -->
<!-- ENDIF -->
 
Add on a new blank line after preceding lines to find:

Code: Select all

<!-- IF CAT_LIST -->
    <!-- INCLUDE portal/block/articles.html -->
<!-- ENDIF -->
 
DIY instructions:
Copy files from attachment, logon to ACP, purge cache. It's done.

Ok, since I can not add any attachments, here is a code for articles.php and articles.html.

Create file "articles.php" on location ./root/portal/block/ of your phpBB3 instalation:

Code: Select all

<?php

/**
*
* @package - Board3portal
* @version $Id: articles.php 001 2010-07-23 10:50:43Z t90 $
* @copyright (c) t90 (busomania.pl)
* @based on: phpBB3 Portal by Sevdin Filiz, www.phpbb3portal.com
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

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

    $sql = "SELECT * FROM `phpbb_articles` ORDER BY `phpbb_articles`.`article_id` ASC";
    $result = mysql_query($sql);
    $i = 0;
        while($row = mysql_fetch_assoc($result))
            {
            $i++;
            $template->assign_block_vars('articles', array(
            'U_TITLE'    => append_sid("{$phpbb_root_path}kb.$phpEx", 'a=' .$row['article_id']),
            'TITLE' => $row['article_title'],
            ));
            }
    $cat_list = ($i > 0) ? true : false; //check if there is anything to show

// Assign index specific vars
$template->assign_vars(array(
    'CAT_LIST'                => $cat_list,
));

?>
Create file "articles.html" on location ./root/styles/prosilver/template/portal/block/ of your phpBB3 instalation:

Code: Select all

{$LR_BLOCK_H_L}<img src="{T_THEME_PATH}/images/icon_kb.gif" width="27" height="22" alt="{L_KB_EXPLAIN}">{L_KB}{$LR_BLOCK_H_R}

    <div class="portal-navigation">
        <div class="menutitle">{ILE}</div>
            <ul>
                <!-- BEGIN articles -->
                <li><a href="{articles.U_TITLE}" title="{articles.TITLE}" title="{articles.TITLE}" alt="{articles.TITLE}">{articles.TITLE}</a></li>
                <!-- END articles -->
            </ul>
    </div>
    {$LR_BLOCK_F_L}{$LR_BLOCK_F_R}
 
Now it's done :-)

Re: PhpBB Knowledge Base Mod on board3 Portal

Posted: 2. August 2010 16:37
by amka
hello!
Tell me how to do that in the block displays the category of "PhpBB Knowledge Base Mod"

P.S. Sorry for my bad English!

Re: PhpBB Knowledge Base Mod on board3 Portal

Posted: 5. August 2010 22:54
by t90
amka wrote:hello!
Tell me how to do that in the block displays the category of "PhpBB Knowledge Base Mod"

P.S. Sorry for my bad English!
It's all there. You need to edit portal.php and left_side_column.html. I have described all steps on first post. After you complete file modifications, you will have to clear cache.

Block is not perfect, but it works. Updated code for articles.php would be:

Code: Select all

<?php

/**
*
* @package - Board3portal
* @version $Id: articles.php 001 2010-07-23 10:50:43Z t90 $
* @copyright (c) t90 (busomania.pl)
* @based on: phpBB3 Portal by Sevdin Filiz, www.phpbb3portal.com
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

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

    $sql = "SELECT * FROM `phpbb_articles` WHERE `article_status` = 1 ORDER BY `phpbb_articles`.`article_id` ASC";
    $result = mysql_query($sql);
    $i = 0;
        while($row = mysql_fetch_assoc($result))
            {
            $i++;
            $template->assign_block_vars('articles', array(
            'U_TITLE'    => append_sid("{$phpbb_root_path}kb.$phpEx", 'a=' .$row['article_id']),
            'TITLE' => $row['article_title'],
            ));
            }
    $cat_list = ($i > 0) ? true : false; //check if there is anything to show

// Assign index specific vars
$template->assign_vars(array(
    'CAT_LIST'                => $cat_list,
));

?>
This way only approved articles will be shown.

Re: PhpBB Knowledge Base Mod on board3 Portal

Posted: 20. August 2010 02:53
by vonhazey
nice how do i limit how many it shows as i have a mega long list and only want 5

Re: PhpBB Knowledge Base Mod on board3 Portal

Posted: 20. August 2010 15:26
by t90
vonhazey wrote:nice how do i limit how many it shows as i have a mega long list and only want 5
This one will give 5 random articles ...

Code: Select all

<?php

/**
*
* @package - Board3portal
* @version $Id: articles.php 001 2010-07-23 10:50:43Z t90 $
* @copyright (c) t90 (busomania.pl)
* @based on: phpBB3 Portal by Sevdin Filiz, www.phpbb3portal.com
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

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

//check if there is anything to show
    $sql = "SELECT * FROM `phpbb_articles` ORDER BY RAND() LIMIT 5";
    $result = mysql_query($sql);
    $i = 0;
        while($row = mysql_fetch_assoc($result))
            {
            $i++;
            $template->assign_block_vars('articles', array(
            'U_TITLE'    => append_sid("{$phpbb_root_path}kb.$phpEx", 'a=' .$row['article_id']),
            'TITLE' => $row['article_title'],
            ));
            }
    $cat_list = ($i > 0) ? true : false;

// Assign index specific vars
$template->assign_vars(array(
    'CAT_LIST'                => $cat_list,
));

?>
If you wish to have more (or less) results just find:

Code: Select all

//check if there is anything to show
    $sql = "SELECT * FROM `phpbb_articles` ORDER BY RAND() LIMIT 5";
 
and change "LIMIT 5" to "LIMIT X" where "X" is your desired number of articles to be shown within a block.

Re: PhpBB Knowledge Base Mod on board3 Portal

Posted: 11. October 2010 15:49
by obiewan
Correct me if i'm wrong; you can only display the articles when you display the forumlist in the portal?


I just tried the block.. and nothing is shown, because i do not want the forumlist to be seen in the portal.

Re: PhpBB Knowledge Base Mod on board3 Portal

Posted: 13. October 2010 05:00
by t90
Well, it has nothing to forum lists. Anyway, I have checked, and knowledge base mod block is shown both, forum lists enabled or disabled.

Re: PhpBB Knowledge Base Mod on board3 Portal

Posted: 13. October 2010 09:57
by obiewan
Ok, thanks :D