News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

[TIP/TRICK] Seperate Stickies from Normal Posts on 2.0 Final

Started by MrGrumpy, August 04, 2011, 12:55:03 PM

Previous topic - Next topic

MrGrumpy

This is an update of the tip posted here http://www.simplemachines.org/community/index.php?topic=17230.0 the code in the original tip isn't quite right for 2.0 final and it also uses hard coded text for the Sticky/Normal posts in the MessageIndex.template.php, this update uses better practice of using $txt strings.




In MessageIndex.template.php

Find


foreach ($context['topics'] as $topic)
{


Replace with


$stickybar = false;
$normalbar = false;
foreach($context['topics'] as $topic)
{
if($topic['is_sticky'] && !$stickybar)
{
echo'<tr class="titlebg"><td colspan="', empty($options['display_quick_mod']) ? '7' : '8', '"><strong>',$txt['Stickied_Topics'],'</strong></td></tr>';
$stickybar = true;
}
else if(!$topic['is_sticky'] && $stickybar && !$normalbar)
{
echo'<tr class="titlebg"><td colspan="', empty($options['display_quick_mod']) ? '7' : '8', '"><strong>',$txt['Normal_Topics'],'</strong></td></tr>';
$normalbar = true;
}




Then you need to add the language strings.

If you are doing this on default Curve theme you need to edit index.english.php in the languages folder and add the following to the bottom before  ?>


$txt['Stickied_Topics'] = 'Stickied Topics';
$txt['Normal_Topics'] = 'Normal Topics';



If you are using a custom theme then see if it has a languages folder with ThemeStrings.english.php then add the following to the bottom before  ?>


$txt['Stickied_Topics'] = 'Stickied Topics';
$txt['Normal_Topics'] = 'Normal Topics';



If your theme doesn't contain a languages folder and ThemeStrings.english.php you will need to create them

Make a folder called languages and upload it to your custom theme.
Then create a file called ThemeStrings.english.php and add the following code in the file and upload it to the languages folder you just created.


<?php
// Version: 2.0; Themes

$txt['Stickied_Topics'] = 'Stickied Topics';
$txt['Normal_Topics'] = 'Normal Topics';
?>



Then in index.template.php

Find

/* Set the following variable to true if this theme requires the optional theme strings file to be loaded. */
$settings['require_theme_strings'] = false;


Replace with

/* Set the following variable to true if this theme requires the optional theme strings file to be loaded. */
$settings['require_theme_strings'] = true;


Obviously if your site is using a language other than English you will need to edit the files for your language and change the theme strings for the titles to your language.
the possession of knowledge is worthless unless imparted upon others
My Custom Themes
2.0 themes only - I don't do 1.1.x

AussieBill

Thanks for the update MrGrumpy. A very simple edit and it looks really good on Curve themes 8)

Advertisement: