News:

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

Main Menu

[TIP] vBulletin style messageindex links

Started by darrenbeige, October 10, 2009, 03:00:24 PM

Previous topic - Next topic

darrenbeige

vBulletin automatically populates the title of links in the MessageIndex to a snippet of that topics first post. With a change to just one line, you can replicate the same effect with SMF.

In Sources/MessageIndex.php:

Code (Find) Select
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0" >' . $row['firstSubject'] . '</a>'

Code (Replace ) Select
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0" title="'. $row['firstBody'].'">' . $row['firstSubject'] . '</a>'

This will show the browser's default 'tooltip' window with a snippet of the message. If you would like to increase the size of the preview, then look a little way above the line you have just edited and change every instance of 128 to the new length. This will increase the size of the preview, however it does slow SMF considerably, as censorText has to iterate over more and more words. There is a negligible PHP performance hit as this data is already loaded in an SMF default installation, but there may be a slight end-user-slowdown as - due to there being more HTML in the source of the page - it naturally takes longer for the browser to download all the content.

To be honest, I don't know why this isn't a default option in SMF, I mean the data's already loaded (and seems to be unused).

Thanks,

Arantor

Looks good. I moved it here for others to use too.

darrenbeige

Thanks for moving it. Why don't they allow posting direct to Tips and Tricks?

BTW, am I right in thinking that firstBody, and lastBody are never used, but loaded 'unneccesarily'? If so, I'm thinking about removing the SQL select for lastBody to speed up my code.

Arantor

The idea is so that only legitimate tips/tricks get posted here, and not endless topics on supporting them too, much as it is in the Modifications and Packages board.

Just updating the SQL select may not produce a huge benefit on its own, but I seem to recall you can't remove the second join. I can't remember offhand if the censor is called separately on them or not.

darrenbeige

Quote from: Arantor on October 11, 2009, 04:55:05 PM
Just updating the SQL select may not produce a huge benefit on its own, but I seem to recall you can't remove the second join. I can't remember offhand if the censor is called separately on them or not.

I'll have a play around. I still can't see why they are there, when they are not used in a default installation.

Arantor

Well, many such things are set up for themes that want to make use of them.

darrenbeige

I thought SMF was of the opinion of reducing bloat. If that is true, then isn't up to the individual templates to add in the extra SQL statements (and censor etc...) needed, NOT to put that functionality in by default and just leave it there, in case of such a happening.

Arantor

I also have a feeling some of the SSI stuff uses a similar query so the developers added it to the message index too in case people wanted to use this in their themes; some do, some don't. But if a theme wanted to offer this it would have to become a mod not a pure theme.

And you may find some of the other base themes may use it too, I can't really remember. Note that queries cannot go in templates anywhere, hence the above.

Joshua Dickerson

Themes are setup to have everything a theme author could want without having to manipulate the sources.
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?


Advertisement: