News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

How to: Bold text for stuck topics?

Started by SilentNoise, September 29, 2004, 05:45:15 PM

Previous topic - Next topic

moaltmann

okay, I know you've been waiting for this combination ;-)

If you want:
  • sticky to be bold preceded by string "Sticky: "
  • locked to be in italics, preceeded by string "Locked: "

and you want this to work for locked and sticky topics then my solution is nesting <span> statements but that's ugly, i.e.

find

', $topic['first_post']['link'];

and replace with (for redability i broke the lines)

                        <span style="
                            ',  $topic['is_sticky'] ? 'font-weight: bold;">Sticky: ' : '">', '
                                <span style="
                                    ', $topic['is_locked'] ? 'font-style: italic;">Locked: ' : '">' ,'
                                    ', $topic['first_post']['link'], '
                                </span>
                        </span>';


can someone make this elegant?

btw, if I were to want to want the test after the topic name I will have to either have two "  ', $topic['first_post']['link'], ' or another set of if-then (', $topic['is_sticky'] ? and so on ).

thanks,
  Mischa

[Unknown]

                        <span style="', $topic['is_sticky'] ? 'font-weight: bold;' : '', $topic['is_locked'] ? 'font-style: italic;' : '', '">
                                ', $topic['is_sticky'] ? 'Sticky: ' : ($topic['is_locked'] ? 'Locked' : ''), ' ', $topic['first_post']['link'], '
                        </span>';


Perhaps?  This is slightly different - a locked sticky will only show "Sticky:", but will be bold and italic.

-[Unknown]

moaltmann

hm, interesting idea.

though performance is of no real importance for me I wonder whether testing for property of topic four times (instead of twice) will have any impact. In my solution I was trying to get away with only one test per property.

I honestly don't know whether it has any impact on a "huge board". (Are such queries cached?) If it does I'd rather go with the nested <span>.

thanks,
  mischa

[Unknown]

Well, it's just a variable.  It wouldn't hardly have that much impact, if you wanted it to be as fast as possible, you'd use an if structure instead of several nested ternaries.

But, once it's compiled it wouldn't matter anyway, so if you have a PHP accelerator/optimizer/cache... it won't really matter, no.  Nor would it depend on the size of the forum, because it would only do it once per every *displayed* topic anyway; which is going to be 20 on large forums and 20 on itty-bitty ones.

-[Unknown]

wba_4_eva

Quote from: [Unknown] on September 29, 2004, 06:08:28 PM
Themes/yourtheme/MessageIndex.template.php:

Find:
', $topic['first_post']['link'];

Replace:
<span', $topic['is_sticky'] ? ' style="font-weight: bold;"' : '', '>', $topic['first_post']['link'], '</span>';

-[Unknown]

When we tried to go on the forums we got a parse error.

Does anyone know how to solve this problem?

Peace out, Andy.

barnjo

Hi there, dunno how todo this now im on SMF 1.1 beta 3 and the source code has changed.

Anyone help please.

ApocryphA

I recently upgraded to 1.1.2 and this doesn't work, giving me parse error.  Any update on this would be greatly appreciated. Mainly, bold for stickied topics and italic for locked topics.

Thanks in advance.

KGIII

In reference to the above question, the code may be a bit dis-similar but you should be able to find what you are looking for if you follow the general idea of what is being done.

My PC Support Forum
Please ask in-thread before PMing
                   SMF Help
                   Visit My Blog

How can we improve the support process?:
http://www.simplemachines.org/community/index.php?topic=163533.0

SMF vs. Godzilla? Who do you think will win?

ApocryphA

Yes, thank you.  I've figured out the code a few minutes after my last post :).  Otherwise I wouldn't have stopped posting :D.  Thanks anyway.

Assistance

I'm actually surprised no one has made a topic multi moderation mod like IPB has.
~playing poker~

codenaught

Quote from: Assistance on June 19, 2007, 07:54:31 AM
I'm actually surprised no one has made a topic multi moderation mod like IPB has.
Not exactly sure how this has to do with this topic? But I wrote a mod for topic multi-moderation awhile ago but just haven't gotten it released. I guess it needs to be polished a little more but then I can release a beta version for testing.
Dev Consultant
Former SMF Doc Coordinator

KERA

in SMF 1.1.2 i cant find that code in message index template!

sup_iran

hi
I dont have ', $topic['first_post']['link']; in this page ! what can I do that?
I can seperate the sticky topics bot I cant bold them.

djrem

Bump please

"You'll work it out" doesnt really suffice for the braindead among us.

Theres more than one instance of similar "Search for this bit" terms.

Nathaniel

The edits below are updated for SMF 1.1.6 and above. :)

For the default theme '/Themes/default/MessageIndex.template.php':
Find this code:
            echo '
                            ', $topic['is_sticky'] ? '<b>' : '' , '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</b>' : '';

Replace with this code:
            echo '
                            ', $topic['is_locked'] ? '<i>' : '', $topic['is_sticky'] ? '<b>' : '' , '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</b>' : '', $topic['is_locked'] ? '</i>' : '';


For custom themes '/Themes/default/MessageIndex.template.php':
Find this code:
', $topic['first_post']['link'], '
Replace with this code:
', $topic['is_locked'] ? '<i>' : '', $topic['is_sticky'] ? '<b>' : '' , $topic['first_post']['link'], $topic['is_sticky'] ? '</b>' : '', $topic['is_locked'] ? '</i>' : '
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

Advertisement: