Advertisement:

Navigation

SMF Mod Site

Mod Name:
Order Stickied Topics
Created By:
Nathaniel
Type:
New Feature
First Created:
August 06, 2008, 08:29:11 AM
Last Modified:
November 11, 2008, 04:06:50 AM
Latest Version:
1.01
Compatible With:
1.1.5, 1.1.6, 1.1.7, 2.0 Beta 3.1 Public, 2.0 Beta 4
Total Downloads:
33769

Download this mod

OrderStickiedTopics_v1.01.tar.gz (4kB) [33688]
Manual Install Instructions for SMF

Description:

Order Stickied Topics version 1.01 by LHVWB
Overview:

This mod allows you to order your stickied topics the way that you want them to be. It allows anyone with permissions to create a sticky in a particular board, to order those stickied topics by clicking on the "Order Stickied Topics" link, on the topic list page for any particular board.

Custom Themes:

This mod edits fairly important template files so its likely that you will have to make edits to each of your custom themes to get it to work for those themes. Please note, that the edits below are only necessary if your custom theme has the 'Post.template.php' or 'MessageIndex.template.php' template files.

If you have SMF 1.1.x:
Find this code from your 'MessageIndex.template.php' file, if your custom theme has that file, please note that this edit may not work, skip to the next edit if it doesn't.
Code: [Select]
'post_poll' => array('test' => 'can_post_poll', 'text' => 'smf20', 'image' => 'new_poll.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'),
Replace with this code:
Code: [Select]
'post_poll' => array('test' => 'can_post_poll', 'text' => 'smf20', 'image' => 'new_poll.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'),
// Show the Link/Button for the Order Stickied Topics Mod.
'order_stickied_topics' => array('test' => 'can_order_stickied_topics', 'text' => 'OrderStickiedTopics_title', 'lang' => true, 'url' => $scripturl . '?action=orderstickiedtopics;board=' . $context['current_board'] . '.0'),

Finally, add this code to the bottom of your 'Post.template.php' file, if your custom theme has it.
Code: [Select]
// Function to display the list of stickiedtopics.
function template_orderstickiedtopics()
{
global $context, $txt, $board_info, $scripturl, $settings;

// Show the start of the table, as well as the main heading and the column headings.
echo '
<br />
<table border="0" align="center" cellspacing="1" cellpadding="4" class="bordercolor" width="60%">
<tr class="catbg3">
<td colspan="5" align="left">
<div style="float: left;">
<b>', $txt['OrderStickiedTopics_title'] ,'</b> - <a href="' . $scripturl . '?board=', $context['current_board'], '.0">', $board_info['name'], '</a>
</div>
</td>
</tr>
<tr class="titlebg">
<th>', $txt[70], '</th>
<th>', $txt['OrderStickiedTopics_current'], '</th>
<th>', $txt['OrderStickiedTopics_modify'], '</th>
</tr>';

// Show a list of the topics.
foreach($context['topics'] as $topic)
{
echo '
<tr>
<td align="left" valign="top" class="windowbg"><b><a href="', $scripturl, '?topic=', $topic['id'], '.0">', $topic['title'], '</a></b></td>
<td align="left" valign="top" class="windowbg2" style="text-align:center;">', $topic['value'], '</td>
<td align="center" valign="top" class="windowbg2">
<a href="', $scripturl, '?action=orderstickiedtopics;topic=', $topic['id'],';decrease"><img src="', $settings['images_url'], '/sort_down.gif" alt="', $txt['OrderStickiedTopics_decrease'], '" border="0" /></a>
<a href="', $scripturl, '?action=orderstickiedtopics;topic=', $topic['id'],';increment"><img src="', $settings['images_url'], '/sort_up.gif" alt="', $txt['OrderStickiedTopics_increase'], '" border="0" /></a>
&nbsp;&nbsp;&nbsp;<a href="', $scripturl, '?action=orderstickiedtopics;topic=', $topic['id'],';unsticky">', $txt['OrderStickiedTopics_unsticky'], '</a>
</td>
</tr>';
}

// If we have no topics, then show a short message telling the moderator.
if(empty($context['topics']))
echo '
<tr>
<td colspan="3" valign="top" class="windowbg">', $txt['OrderStickiedTopics_emptylist'], '</td>
</tr>';

// Finish the table.
echo '
<tr class="catbg3">
<td colspan="5" align="left">
<b style="font-size:14px;"><a href="', $scripturl, '?board=', $context['current_board'], '.0">', $txt['OrderStickiedTopics_back'], ' ', $board_info['name'], '</a></b>
</td>
</tr>
</table>';
}

If you have SMF 2:
Find this code from your 'MessageIndex.template.php' file, if your custom theme has that file.
Code: [Select]
'post_poll' => array('test' => 'can_post_poll', 'text' => 'new_poll', 'image' => 'new_poll.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'),
Replace with this code:
Code: [Select]
'post_poll' => array('test' => 'can_post_poll', 'text' => 'new_poll', 'image' => 'new_poll.gif', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'),
// Show the Link/Button for the Order Stickied Topics Mod.
'order_stickied_topics' => array('test' => 'can_order_stickied_topics', 'text' => 'OrderStickiedTopics_title', 'lang' => true, 'url' => $scripturl . '?action=orderstickiedtopics;board=' . $context['current_board'] . '.0'),

Finally, add this code to the bottom of your 'Post.template.php' file, if your custom theme has it.
Code: [Select]
// Function to display the list of stickiedtopics.
function template_orderstickiedtopics()
{
global $context, $txt, $board_info, $scripturl, $settings;

// Show the start of the table, as well as the main heading and the column headings.
echo '
<br />
<table border="0" align="center" cellspacing="1" cellpadding="4" class="bordercolor" width="60%">
<tr class="catbg3">
<td colspan="5" align="left">
<div style="float: left;">
<b>', $txt['OrderStickiedTopics_title'] ,'</b> - <a href="' . $scripturl . '?board=', $context['current_board'], '.0">', $board_info['name'], '</a>
</div>
</td>
</tr>
<tr class="titlebg">
<th>', $txt['subject'], '</th>
<th>', $txt['OrderStickiedTopics_current'], '</th>
<th>', $txt['OrderStickiedTopics_modify'], '</th>
</tr>';

// Show a list of the topics.
foreach($context['topics'] as $topic)
{
echo '
<tr>
<td align="left" valign="top" class="windowbg"><b><a href="', $scripturl, '?topic=', $topic['id'], '.0">', $topic['title'], '</a></b></td>
<td align="left" valign="top" class="windowbg2" style="text-align:center;">', $topic['value'], '</td>
<td align="center" valign="top" class="windowbg2">
<a href="', $scripturl, '?action=orderstickiedtopics;topic=', $topic['id'],';decrease"><img src="', $settings['images_url'], '/sort_down.gif" alt="', $txt['OrderStickiedTopics_decrease'], '" border="0" /></a>
<a href="', $scripturl, '?action=orderstickiedtopics;topic=', $topic['id'],';increment"><img src="', $settings['images_url'], '/sort_up.gif" alt="', $txt['OrderStickiedTopics_increase'], '" border="0" /></a>
&nbsp;&nbsp;&nbsp;<a href="', $scripturl, '?action=orderstickiedtopics;topic=', $topic['id'],';unsticky">', $txt['OrderStickiedTopics_unsticky'], '</a>
</td>
</tr>';
}

// If we have no topics, then show a short message telling the moderator.
if(empty($context['topics']))
echo '
<tr>
<td colspan="3" valign="top" class="windowbg">', $txt['OrderStickiedTopics_emptylist'], '</td>
</tr>';

// Finish the table.
echo '
<tr class="catbg3">
<td colspan="5" align="left">
<b style="font-size:14px;"><a href="', $scripturl, '?board=', $context['current_board'], '.0">', $txt['OrderStickiedTopics_back'], ' ', $board_info['name'], '</a></b>
</td>
</tr>
</table>';
}

TroubleShooting
If you couldn't manage to get the first edit to work for either version of SMF, then you should be able to find the 'theme_show_buttons()' function at the bottom of the
'MessageIndex.template.php' File, you will notice that there are a
series of buttons there. The exact code for this will change from theme to theme, but you have to copy one of the chucks of code and past it near the end of the function (just before the "return" code), like the example below (classic theme):

Code: [Select]
// How about new polls, can the user post those?
if ($context['can_post_poll'])
$buttonArray[] = '<a href="' . $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll">' . ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new_poll.gif" alt="' . $txt['smf20'] . '" border="0" />' : $txt['smf20']) . '</a>';


You will also have to replace the $txt['smf20'] or $txt['new_poll'] with $txt['OrderStickiedTopics_title'], and the $context['can_post_poll'] with $context['can_order_stickied_topics'].

A finished example could look like this (classic theme):
Code: [Select]
// How about new polls, can the user post those?
if ($context['can_order_stickied_topics'])
$buttonArray[] = '<a href="' . $scripturl . '?action=orderstickiedtopics;board=' . $context['current_board'] . '.0">' . ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new_topic.gif" alt="' . $txt['OrderStickiedTopics_title'] . '" border="0" />' : $txt['OrderStickiedTopics_title']) . '</a>';

If you are having trouble getting the actual text or links for the mod to display in your custom theme, then its possible that you custom theme has its own 'languages/Modifications.english.php' file. If your theme has its own 'languages/Modifications.english.php' file then you will need to copy the language strings/code from the default themes 'languages/Modifications.english.php' file ('/themes/default/languages/Modifications.english.php') into to your custom themes 'Modifications.english.php' file, so that you have the correct language strings for the custom theme. If you are using english-utf, then the steps will be the same, except that you will have to deal with the 'Modifications.english-utf8.php' files instead.

Please note, that this mod does not include any images for these 'MessageIndex.template.php' buttons, if your custom theme uses images, then you will have to make your own.

If you need any help with edits for custom themes, then you can ask for it in the Support Topic for this Mod, However you will have to post the custom template files as well, otherwise I will not be able to perform the edits.


Version Changes:

v1.01
Fixed a spelling mistake, for the title ('Sticked ' => 'Stickied ').

v1.0
Original Mod release.