Dual Column Layout (Tutorial) (IPB 2.2.x & 2.3.x)

Status
Not open for further replies.

Phamous

Active Member
2,284
2009
892
0
This mod will display two forums per row, inspired by Gaia Online.


Open sources/action_public/boards.php

The first set of edits all occur in function show_subfroum($fid).

FIND: (around line 211)
PHP:
$temp_html = "";
$sub_output = "";

ADD AFTER:
PHP:
$subrowCount = 0;

FIND: (Around line 236)
PHP:
foreach( $this->ipsclass->forums->forum_cache[ $fid ] as $forum_data )
{

ADD AFTER:
PHP:
$subrowCount++;

FIND (around 254)

PHP:
if ( $forum_data['redirect_on'] )
{
    $forum_data['redirect_hits']    = $this->ipsclass->do_number_format( $forum_data['redirect_hits'] );
    $forum_data['redirect_target']     = isset($forum_data['redirect_target']) ? $forum_data['redirect_target'] : '_parent';
    $temp_html .= $this->ipsclass->compiled_templates['skin_boards']->forum_redirect_row( $forum_data );
}
else
{
    $temp_html .= $this->ipsclass->compiled_templates['skin_boards']->ForumRow( $this->ipsclass->forums->forums_format_lastinfo( $this->ipsclass->forums->forums_calc_children( $forum_data['id'], $forum_data ) ) );
}
}
}
if ( $temp_html )
{
$sub_output .= $this->ipsclass->compiled_templates['skin_boards']->subheader($cat_data);
$sub_output .= $temp_html;
$sub_output .= $this->ipsclass->compiled_templates['skin_boards']->end_this_cat();
}
else
{
    return $sub_output;
}


REPLACE WITH:

PHP:
if ( $forum_data['redirect_on'] )
{
    $forum_data['redirect_hits']    = $this->ipsclass->do_number_format( $forum_data['redirect_hits'] );
    $forum_data['redirect_target']     = isset($forum_data['redirect_target']) ? $forum_data['redirect_target'] : '_parent';
    $temp_html .= $this->ipsclass->compiled_templates['skin_boards']->forum_redirect_row( $forum_data );
}
else
{
    $temp_html .= $this->ipsclass->compiled_templates['skin_boards']->ForumRow( $this->ipsclass->forums->forums_format_lastinfo( $this->ipsclass->forums->forums_calc_children( $forum_data['id'], $forum_data ) ) );
}
// If we have displayed 2 forums to display, move to the next row
if ($subrowCount % 2 == 0)
{
    $temp_html .= $this->ipsclass->compiled_templates['skin_boards']->rowbreak();
}
}
//If we only have 1 forum in a row when we run out of them, print a blank td..
if ($subrowCount % 2 == 1)
{
    $temp_html .= $this->ipsclass->compiled_templates['skin_boards']->emptytd();
}
//Reset our count to 0
$subrowCount = 0;
}
if ( $temp_html )
{
$sub_output .= $this->ipsclass->compiled_templates['skin_boards']->subheader($cat_data);
$sub_output .= $temp_html;
$sub_output .= $this->ipsclass->compiled_templates['skin_boards']->end_this_cat();
}
else
{
return $sub_output;
}


You're halfway there. The exact same edits have to be done to the full forums though, so lets go!

This set of edits all take place in function process_all_cats().

FIND: (around 335)

PHP:
//-----------------------------------------
// Get show / hide cookah
//-----------------------------------------
        
$collapsed_ids = ','.$this->ipsclass->my_getcookie('collapseprefs').',';
$this->ipsclass->forums->register_class( $this );


Add AFTER:
CODE
PHP:
$rowCount = 0;

Find (around 391)

PHP:
foreach( $this->ipsclass->forums->forum_cache[ $forum_data['id'] ] as $forum_data )
{


Add After:
PHP:
$rowCount++;


Find (by 394):

PHP:
if ( $forum_data['redirect_on'] )
{
    $forum_data['redirect_target'] = isset($forum_data['redirect_target']) ? $forum_data['redirect_target'] : '_parent';
    $temp_html .= $this->ipsclass->compiled_templates['skin_boards']->forum_redirect_row( $forum_data );
}
else
{
    $temp_html .= $this->ipsclass->compiled_templates['skin_boards']->ForumRow( $this->ipsclass->forums->forums_format_lastinfo( $this->ipsclass->forums->forums_calc_children( $forum_data['id'], $forum_data ) ) );
}
}
}
    if ( $temp_html )
{
    $this->output .= $this->ipsclass->compiled_templates['skin_boards']->CatHeader_Expanded($cat_data);
    $this->output .= $temp_html;
    $this->output .= $this->ipsclass->compiled_templates['skin_boards']->end_this_cat();
}


Replace With:

PHP:
if ( $forum_data['redirect_on'] )
{
    $forum_data['redirect_target'] = isset($forum_data['redirect_target']) ? $forum_data['redirect_target'] : '_parent';
    $temp_html .= $this->ipsclass->compiled_templates['skin_boards']->forum_redirect_row( $forum_data );
}
else
{
    $temp_html .= $this->ipsclass->compiled_templates['skin_boards']->ForumRow( $this->ipsclass->forums->forums_format_lastinfo( $this->ipsclass->forums->forums_calc_children( $forum_data['id'], $forum_data ) ) );
}
if ($rowCount % 2 == 0)
{
    $temp_html .= $this->ipsclass->compiled_templates['skin_boards']->rowbreak();
}
}
if ($rowCount % 2 == 1)
{
    $temp_html .= $this->ipsclass->compiled_templates['skin_boards']->emptytd();
}
$rowCount = 0;
}
if ( $temp_html )
{
    $this->output .= $this->ipsclass->compiled_templates['skin_boards']->CatHeader_Expanded($cat_data);
    $this->output .= $temp_html;
    $this->output .= $this->ipsclass->compiled_templates['skin_boards']->end_this_cat();
}


Save boards.php. Time for some skin edits..

Open Skin manager -> your skin -> edit template HTML -> Board Index
Scroll to the bottom of the right panel (add new template)
Template name: emptytd
Click "continue"

In the white screen, paste
PHP:
<!-- Used in custom forum row -->
<td colspan="2" class="row2"><!-- empty td --></td>
Save Template Bit

Add a new template.
Template name: rowbreak
Click "continue"

In the white screen, paste
PHP:
<!-- Used in custom forum row -->
</tr><tr>
Save Template Bit

Open CatHeader_Expanded
Find


Replace With:

PHP:
<table class='ipbtable' cellspacing="1">
<tr>

Open subheader
Find
PHP:
<table class='ipbtable' cellspacing="0">
<tr> 
    <th colspan="2" width="66%">{$this->ipsclass->lang['cat_name']}</th>
    <th align="center" width="7%">{$this->ipsclass->lang['topics']}</th>
    <th align="center" width="7%">{$this->ipsclass->lang['replies']}</th>
    <th width="35%">{$this->ipsclass->lang['last_post_info']}</th>
</tr>

Replace With:
PHP:
<table class='ipbtable' cellspacing="1">
<tr>


Open ForumRow
Replace the contents with:
PHP:
<td class="row2" width="50%" style="vertical-align: top;">
{$data['img_new_post']} &nbsp; <b><a href="{$this->ipsclass->base_url}showforum={$data['id']}">{$data['name']}</a></b>
<br />
<span class="forumdesc">{$data['description']}{$data['show_subforums']}                                <if="$data['moderator']">
    <br /><i>{$data['moderator']}</i>
</if></td>

You're finally done. Enjoy.
 
13 comments
Status
Not open for further replies.
Back
Top