Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Elmacik - joulukuu 13, 2005, 03:09:24 IP

Otsikko: Checking stickies in messageindex
Kirjoitti: Elmacik - joulukuu 13, 2005, 03:09:24 IP
How to check and act according to that if there is/are sticky topic(s) in a board?
For example I want to make a picture display above and below the stickies..
So when there is/are sticky topic(s) it will display, when there isnt/arent, it wont.

Please note: I am NOT asking how to seperate stickies/normal posts.

One another question: When adding a button to post template, is there an extra work to highlight it like others? My buttons didnt auto highlight (mouseover)
Otsikko: Re: Checking stickies in messageindex
Kirjoitti: Thantos - joulukuu 13, 2005, 03:36:59 IP
File:  MessageIndex.template.php
Find:

                foreach ($context['topics'] as $topic)
                {
                        // Do we want to seperate the sticky and lock status out?
                        if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
                                $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
                        if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
                                $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));



Replace with

                $isSticky = false;
                foreach ($context['topics'] as $topic)
                {
                        // Do we want to seperate the sticky and lock status out?
                        if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
                                $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
                        if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
                                $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

                        if ( !$isSticky && $topic['is_sticky'] )
                        {
                                $isSticky = !$isSticky;
                                echo '
                                        Above Code Here';
                        }

                        if ( $isSticky && !$topic['is_sticky'] )
                        {
                                $isSticky = !$isSticky;
                                echo '
                                        Below Code Here';
                        }
Otsikko: Re: Checking stickies in messageindex
Kirjoitti: Elmacik - joulukuu 13, 2005, 05:09:29 IP
MikeMill, you always do that and give the codes of un-released versions :P
Thanks though, you are still great ;D
Otsikko: Re: Checking stickies in messageindex
Kirjoitti: Thantos - joulukuu 13, 2005, 05:15:25 IP
Its because of my future seeing abilities :)

Though I think the basic structure is the same