News:

Wondering if this will always be free?  See why free is better.

Main Menu

Separating the sticky topics from the normal ones

Started by Alexandre P., September 05, 2004, 06:23:54 PM

Previous topic - Next topic

kill3r


eugene_lazarev

#101
hey!

i use this tip, but i need to mark all "normal" topics ALWAYS, not only when "important" topics are.

what's needing to change?


p.s. sorry for my English)

Neorics

[For Hire] I can help you with anything regarding Simple Machines Forum  ~ My Portfolio

jesuscamp1

#103
Quote from: Ben_S on September 05, 2004, 06:37:36 PM
Tips and tricks I beleive.

Well it did, but now the topic is in the bin ???

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', '"><b>Important Topics</b></td></tr>';
$stickybar = true;
}
else if(!$topic['is_sticky'] && $stickybar && !$normalbar)
{
echo'<tr class="titlebg"><td colspan="', empty($options['display_quick_mod']) ? '7' : '8', '"><b>Normal Topics</b></td></tr>';
$normalbar = true;
}


I take no credit for that, just a copy and paste.

Thank you!!!!  ;D

in spanish

Muchas gracias
Version: SMF 1.1.6

Web: http://animezerofansub.org


hayley2007

why doesnt Ben_s one work for me? im on 1.1.4 when i do the code change, nothing changes at all :/

ham1299

Heather

Sarge

Quote from: hayley2007 on October 29, 2007, 04:56:56 AM
why doesnt Ben_s one work for me? im on 1.1.4 when i do the code change, nothing changes at all :/

Are you sure the modified file overwrote the original when you uploaded it?

Download it again and see if it contains the changes you made.

    Please do not PM me with support requests unless I invite you to.

http://www.zeriyt.com/   ~   http://www.galeriashqiptare.net/


Quote
<H> I had zero posts when I started posting

seymoor

same thing happening to me, as nothing happening after the modification.

sources/messageindex.php
// Set permissions for all the topics.
foreach ($context['topics'] as $t => $topic)
{
if (isset($previousTopicClass) && strpos($previousTopicClass, 'sticky') !== false && !$topic['is_sticky'])
      echo '
         <tr class="titlebg">
         <td colspan="2">&nbsp;</td>
         <td colspan="7">&nbsp;</td>
         </tr>';
$previousTopicClass = $topic['class'];

$started = $topic['first_post']['member']['id'] == $ID_MEMBER;
$context['topics'][$t]['quick_mod'] = array(
'lock' => allowedTo('lock_any') || ($started && allowedTo('lock_own')),
'sticky' => allowedTo('make_sticky') && !empty($modSettings['enableStickyTopics']),
'move' => allowedTo('move_any') || ($started && allowedTo('move_own')),
'modify' => allowedTo('modify_any') || ($started && allowedTo('modify_own')),
'remove' => allowedTo('remove_any') || ($started && allowedTo('remove_own'))
);
$context['can_lock'] |= ($started && allowedTo('lock_own'));
$context['can_move'] |= ($started && allowedTo('move_own'));
$context['can_remove'] |= ($started && allowedTo('remove_own'));
}



is it in the wrong place or...?

Mick.

I think i found a problem here.

In the 2nd posts,states to find:

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


But i found this instead:

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


which there not the same?

Any way to rewrite the tip?


Oldiesmann

Quote from: seymoor on December 18, 2007, 04:12:41 PM
same thing happening to me, as nothing happening after the modification.

sources/messageindex.php
// Set permissions for all the topics.
  foreach ($context['topics'] as $t => $topic)
  {
if (isset($previousTopicClass) && strpos($previousTopicClass, 'sticky') !== false && !$topic['is_sticky'])
      echo '
         <tr class="titlebg">
         <td colspan="2">&nbsp;</td>
         <td colspan="7">&nbsp;</td>
         </tr>';
$previousTopicClass = $topic['class'];
 
   $started = $topic['first_post']['member']['id'] == $ID_MEMBER;
   $context['topics'][$t]['quick_mod'] = array(
    'lock' => allowedTo('lock_any') || ($started && allowedTo('lock_own')),
    'sticky' => allowedTo('make_sticky') && !empty($modSettings['enableStickyTopics']),
    'move' => allowedTo('move_any') || ($started && allowedTo('move_own')),
    'modify' => allowedTo('modify_any') || ($started && allowedTo('modify_own')),
    'remove' => allowedTo('remove_any') || ($started && allowedTo('remove_own'))
   );
   $context['can_lock'] |= ($started && allowedTo('lock_own'));
   $context['can_move'] |= ($started && allowedTo('move_own'));
   $context['can_remove'] |= ($started && allowedTo('remove_own'));
  }



is it in the wrong place or...?
You're modifying the wrong file. You want to modify Themes/default/Messageindex.template.php, not Sources/Messageindex.php.

Quote from: BlueDevil on December 23, 2007, 04:26:30 PM
I think i found a problem here.

In the 2nd posts,states to find:

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


But i found this instead:

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


which there not the same?

Any way to rewrite the tip?


It shouldn't matter. The only difference is that the code you found is separating the array keys into a separate variable. You're only interested in the array values.
Michael Eshom
Christian Metal Fans

Mick.


Antechinus

#111
I want to have a go at updating this for SMF 2 but the code I'm supposed to find doesn't exist. Has anyone already sorted this for SMF 2?

ETA: Ok, found the code line. In 2b4 there is a space in it which threw my first search result off. No problem. This code works as advertised in 2b4 with no alteration. Just remember to change this line at the beginning of the file from this:

global $context, $settings, $options, $scripturl, $modSettings, $txt;

to this:

global $context, $settings, $options, $scripturl, $modSettings, $txt, $stickybar, $normalbar;

If you don't do this you may get undefined index errors.

Stuart

I really like this option but would also love to separate the active topics from the ones which are locked. It would be great if all these locked topics could be sorted and end up underneath the normal topics. Any ideas?

Kindred

well, by nature, the locked and unposted-in (but still sticky) topics will end up at the bottom of the sticky list as the more frequently posted to sticky topics get more recent dates.

However, I belive there is a mod that allows you to order your sticky topics.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

coldfusionpower

im getting this after changing the code according this on SMF 2.0.4

Parse error: syntax error, unexpected $end in .../Themes/BlackRainV2_20b4/MessageIndex.template.php on line 513

504:





$buttonArray[] = '<a href="' . $scripturl . '?action=post;board=' . $context['current_board'] . '.0">' . $txt['new_topic'] . '</a>';
505:
506:



// How about new polls, can the user post those?
507:



if ($context['can_post_poll'])
508:





$buttonArray[] = '<a href="' . $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll">' . $txt['new_poll'] . '</a>';
509:
510:



return implode('  |  ', $buttonArray);
511: }
512:

513: ?>

coldfusionpower


Antechinus

Attach the whole file. The error is somewhere else, because this hack doesn't touch the end of the file.

Lamarck

Hi,can someone modify this code to work with Global Topics Mod in SMF 2.0 RC1??

It would be nice,the modification doesn't work properly with global topics MOD installed.I want global topics shown with stickys (separate from normal topics).

Any help? Thanks and sorry for my bad english.

STS

Quote from: [Unknown] on October 01, 2004, 03:10:10 AM

if (isset($previousTopicClass) && strpos($previousTopicClass, 'sticky') !== false && !$topic['is_sticky'])
echo '
<tr class="titlebg" style="font-size: 1ex;">
<td colspan="2">&nbsp;</td>
<td colspan="7">&nbsp;</td>
</tr>';
$previousTopicClass = $topic['class'];


-[Unknown]

This worked FANTASTIC. I removed the &nbsp; and that gave me the exact divider size I wanted. Thanks much.

steve51184


Advertisement: