IPB: Pinned Topic background colours

So, through necessity I’ve figured out a way to highlight the background colours of pinned topics for Invision Power Board 2.3.x and thought I’d share my solution with everyone.

Getting the pinned topics to highlight is quite a simple procedure and takes approximately 10 minutes to complete. It involves editing two template files found in Forum Index, these are: render_pinned_start and render_forum_row. Code edits are highlighted in blue.


Step 1

Involves adding a style="background:#;" to the td in render_pinned_start. This will overwrite the background property that is defined in the darkrow1 class. This edit adjusts the background colour for the Important Topics title.

<!–PINNED–>
<if="$show == 1">
<tr>
<td class="darkrow1" colspan="8" style="background:#fbf2ca;"><b>{$this->ipsclass->lang['pinned_start']}</b></td>
</tr>
</if>
<!– END PINNED –>


Step 2

This is the more time consuming part and involves adding some if, else statements and style code to render_forum_row. What you see below is pretty much the standard code duplicated in order to use the functionality of if, else statements.

Open your favourite text editor, then simply copy and paste the content from render_forum_row in it. Then duplicate the code from <tr> to </tr> within your text document. You then want to add <if="$data['tid'] == your-topic-id || $data['tid'] == your-topic-id"> at the very top of your code. Replace your-topic-id with the pinned topic ID’s off your forum (you will find them if you view source).

The example in my code shows two ID variables because I have more than one pinned topic. You will need to add an additional || $data['tid'] == for each topic ID.

Where the first </tr> ends and second <tr> begins, between these two you want to place an <else /> statement. This basically tells IPB how to display topics if the ID’s from the if statement don’t match. At the end of the second </tr>, place an </if>, this will close off the if statement which you started at the very top of all the code.

From here, all that is left to do is add style="background:#;" with your own colour code to each of the td cells above the <else /> line of code. My final step was to add style="font-weight:bold;" to pinned topic title so that it stands out more.

The final result, complete code:

<if="$data['tid'] == your-topic-id || $data['tid'] == your-topic-id">
<!– Begin Topic Entry {$data['tid']} –>
<tr>
<td align="center" class="$class2" style="background:#fffbe9;" id='tid-folder-{$data['tid']}' onclick='return topic_toggle_folder("{$data['tid']}", "{$data['state']}");'>{$data['folder_img']}</td>
<td align="center" class="$class2" style="background:#fffbe9;"></td>
<td class="$class2" valign="middle" style="background:#fffbe9;">
<div style='float:right'>{$data['_rate_img']}</div>
<div>
{$data['go_new_post']}{$data['prefix']} {$data['attach_img']}<span id='tid-span-{$data['tid']}'><a id="tid-link-{$data['tid']}" href="{$this->ipsclass->base_url}showtopic={$data['tid']}" title="{$this->ipsclass->lang['topic_started_on']} {$data['start_date']}" style="font-weight:bold;">{$data['title']}</a></span> {$data['PAGES']}
<div class="desc"><span onclick='return span_desc_to_input("{$data['tid']}");' id='tid-desc-{$data['tid']}'>{$data['description']}</span></div>
</div>
</td>
<td align='center' class="$classposts" style="background:#fffbe9;">
{$data['posts']}
<if="$data['_hasqueued'] == 1 and $inforum == 1">
&nbsp;<a href="{$this->ipsclass->base_url}showtopic={$data['tid']}&amp;modfilter=invisible_posts"><{BC_QUEUED_POSTS}></a>
</if>
</td>
<td align="center" class="$class2" style="background:#fffbe9;">{$data['starter']}</td>
<td align="center" class="$class1" style="background:#fffbe9;">{$data['views']}</td>
<td class="$class2" style="background:#fffbe9;"><span class="lastaction">{$data['last_post']}<br /><a href="{$this->ipsclass->base_url}showtopic={$data['tid']}&amp;view=getlastpost">{$data['last_text']}</a> <b>{$data['last_poster']}</b></span></td>
<if="$this->ipsclass->member['is_mod'] == 1 and $inforum == 1 and $data['tidon'] == 1">
<td align="center" class="$class1"><input type='hidden' name='tid_{$data['real_tid']}' id='tid_{$data['real_tid']}' /><a href="#" title="{$this->ipsclass->lang['click_for_mod']}" onclick="forum_toggle_tid('{$data['real_tid']}'); return false;"><img name="img{$data['real_tid']}" id='ipb-topic-{$data['real_tid']}' src="{$this->ipsclass->vars['img_url']}/topic_selected.gif" alt='' /></a></td>
</if>
<if="$this->ipsclass->member['is_mod'] == 1 and $inforum == 1 and $data['tidon'] == 0">
<td align="center" class="$class1" style="background:#fffbe9;"><input type='hidden' name='tid_{$data['real_tid']}' id='tid_{$data['real_tid']}' /><a href="#" title="{$this->ipsclass->lang['click_for_mod']}" onclick="forum_toggle_tid('{$data['real_tid']}'); return false;"><img name="img{$data['real_tid']}" id='ipb-topic-{$data['real_tid']}' src="{$this->ipsclass->vars['img_url']}/topic_unselected.gif" alt='' /></a></td>
</if>
</tr>
<else />
<tr>
<td align="center" class="$class2" id='tid-folder-{$data['tid']}' onclick='return topic_toggle_folder("{$data['tid']}", "{$data['state']}");'>{$data['folder_img']}</td>
<td align="center" class="$class2">{$data['topic_icon']}</td>
<td class="$class2" valign="middle">
<div style='float:right'>{$data['_rate_img']}</div>
<div>
{$data['go_new_post']}{$data['prefix']} {$data['attach_img']}<span id='tid-span-{$data['tid']}'><a id="tid-link-{$data['tid']}" href="{$this->ipsclass->base_url}showtopic={$data['tid']}" title="{$this->ipsclass->lang['topic_started_on']} {$data['start_date']}">{$data['title']}</a></span> {$data['PAGES']}
<div class="desc"><span onclick='return span_desc_to_input("{$data['tid']}");' id='tid-desc-{$data['tid']}'>{$data['description']}</span></div>
</div>
</td>
<td align='center' class="$classposts">
{$data['posts']}
<if="$data['_hasqueued'] == 1 and $inforum == 1">
&nbsp;<a href="{$this->ipsclass->base_url}showtopic={$data['tid']}&amp;modfilter=invisible_posts"><{BC_QUEUED_POSTS}></a>
</if>
</td>
<td align="center" class="$class2">{$data['starter']}</td>
<td align="center" class="$class1">{$data['views']}</td>
<td class="$class2"><span class="lastaction">{$data['last_post']}<br /><a href="{$this->ipsclass->base_url}showtopic={$data['tid']}&amp;view=getlastpost">{$data['last_text']}</a> <b>{$data['last_poster']}</b></span></td>
<if="$this->ipsclass->member['is_mod'] == 1 and $inforum == 1 and $data['tidon'] == 1">
<td align="center" class="$class1"><input type='hidden' name='tid_{$data['real_tid']}' id='tid_{$data['real_tid']}' /><a href="#" title="{$this->ipsclass->lang['click_for_mod']}" onclick="forum_toggle_tid('{$data['real_tid']}'); return false;"><img name="img{$data['real_tid']}" id='ipb-topic-{$data['real_tid']}' src="{$this->ipsclass->vars['img_url']}/topic_selected.gif" alt='' /></a></td>
</if>
<if="$this->ipsclass->member['is_mod'] == 1 and $inforum == 1 and $data['tidon'] == 0">
<td align="center" class="$class1"><input type='hidden' name='tid_{$data['real_tid']}' id='tid_{$data['real_tid']}' /><a href="#" title="{$this->ipsclass->lang['click_for_mod']}" onclick="forum_toggle_tid('{$data['real_tid']}'); return false;"><img name="img{$data['real_tid']}" id='ipb-topic-{$data['real_tid']}' src="{$this->ipsclass->vars['img_url']}/topic_unselected.gif" alt='' /></a></td>
</if>
</tr>
</if>
<!– End Topic Entry {$data['tid']} –>



Filed in General, Web








Delayed Movie Reviews

 view all

General

 view all

TV

 view all

iPhone

 view all

Mac

 view all

Books

 view all









UnwittinglyRad is an ongoing blog of the thoughts and ramblings of Rad Berent which may or may not be coherent, but hopefully interesting & entertaining.
mail: me@unwittinglyrad.com  |  twitter: @unwittinglyrad
© Copyright 2009-2012