TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 10:08:57 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,106
  • Total Topics: 21,213
  • Online today: 358
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 115
  • Total: 115

[Discussion] Recent TOPICS scrolling with hover over previews.

Started by prometheus fire, January 03, 2010, 02:09:26 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

prometheus fire

Edit by freddy888 :   Click here to get the code.



Note: this is a split topic and a modification of the block code found at http://www.tinyportal.net/index.php?topic=31632

The changes discussed here are to display a scrolling recent TOPICS block; the other block thread is for displaying a scrolling recent POSTS block.



Hmmmm....it wasn't obvious at first but the only issue I've noticed is that busy topics show up more than once in the list.

The way it fetching the information means that a hotter topics show up everytime they get a post. Instead of showing the 10 most recent topics it is showing the 10 most recent posts. This makes a lot of repitition in the list. I'm looking at the original block that you made with MRCare and the differences are obvious but its not clear what to adjust since the code being used now is from SSI.php is a drastically different from what what used before.

prometheus fire

I went back into SSI.php to have a look at the code you pulled out (great job editing it down, because there is a lot that you streamlined).

I noticed that there are two "recent" sections. One for posts and one for topics. Here is the comments for each section:

For recent posts (this is the one currently used causing the repetition in the list)
// Recent post list:   [board] Subject by Poster Date
function ssi_recentPosts($num_recent = 8, $exclude_boards = null, $output_method = 'echo')


and, for recent topics:
// Recent topic list:   [board] Subject by Poster Date
function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $output_method = 'echo')


Now - looking into each section individually, in the db_query section there are very minor differences in there that I'm not sure how to use. I know something in the latter, topics, section needs to be used, but I'm not sure what.

This may also effect the recent non-scrolling version of this block script you posted.

Freddy

Ok thanks, well at least we are getting somewhere :)

I will look into that, I know exactly what you mean - I think it would be better if it just worked the way the regular TP recent posts work - ie, with just the one entry like you were explaining.

Leave it with me for a bit longer - I can always post two versions of the code.

Freddy

Yes - it seems I got my topics and my posts mixed up when I was looking at SSI.php

I'll just amend the threads I have posted before I do anything else.

prometheus fire

#4
OKay, I managed to fix the repetition problem, I pulled the code from the "recent topics" section of SSI.php (this is the latter section that I listed above)

So, for this code block, we should:

Find:
// Find all the posts.  Newer ones will have higher IDs.
// This is stripped down from SSI.php

$request = db_query("
SELECT
m.subject, m.ID_TOPIC, m.ID_MSG,
LEFT(m.body, ". (!empty($modSettings['NiceTooltips_lenght']) ? $modSettings['NiceTooltips_lenght'] : 384) .") AS body
FROM ({$db_prefix}messages AS m, {$db_prefix}boards AS b)
WHERE m.ID_MSG >= " . ($modSettings['maxMsgID'] - 25 * min($num_recent, 5)) . "
AND b.ID_BOARD = m.ID_BOARD" . (empty($exclude) ? '' : "
AND b.ID_BOARD NOT IN (" . implode(', ', $exclude) . ")") . "
AND $user_info[query_see_board]
ORDER BY m.ID_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);


and, Replace with:
// Find all the posts in distinct topics.  Newer ones will have higher IDs.
// This is stripped down from SSI.php

$request = db_query("
SELECT
m.subject, m.ID_TOPIC, m.ID_MSG,
LEFT(m.body, ". (!empty($modSettings['NiceTooltips_lenght']) ? $modSettings['NiceTooltips_lenght'] : 384) .") AS body
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 25 * min($num_recent, 5)) . "
AND t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($exclude) ? '' : "
AND b.ID_BOARD NOT IN (" . implode(', ', $exclude) . ")") . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAST_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);


The only problem to smooth out is to force the display (is this the array section of your code?) to display the topic name not the message name/subject as it currently does. Instead of:

Jimmy's new trucks it is showing Re: Jimmy's new trucks

This is because we are having it display the topics based on the most recent message so it is displaying the subject for that message. What would be cleaner is to have it display the topic name while still showing the most recent message in the popup (I believe this how your original code for this block worked).

UPDATE: I tried a number of things to remove the Re: and to display the topic name but I can't figure it out. I just don't understand enough about dbase queries and php. It looks like we are requesting all the info from the dbase, but I don't get what we need to do to output the relevant pieces.

Freddy

Yes I see what you mean... hmm I think I need a coffee.  I will pick up where you left off when I get back.

BTW, I split this thread off into one about the TOPICS version.... as that is what we are working on.

Silly me, for picking the wrong function, but hey we get four new blocks instead of two eventually.

Freddy

Try changing the query to this :

$request = db_query("
SELECT
ms.subject, m.ID_TOPIC, m.ID_MSG,
LEFT(m.body, ". (!empty($modSettings['NiceTooltips_lenght']) ? $modSettings['NiceTooltips_lenght'] : 384) .") AS body
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . "
AND t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($exclude_boards) ? '' : "
AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAST_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);


You needed to use ms.subject rather than m.subject at the top....

It seems to be working okay here.

If that all works and you can confirm it I will post it as a new block and link back to this thread.

Thanks for putting that note at the top :)

prometheus fire

#7
confirmed. that's great work. looks like we can consider this one complete. thanks for that work and your knowledge.

anyone wanting to see this working can see it at http://leafboxtea.com

Freddy

Thanks and you are welcome :)

For anyone who missed it : Click here to get the code.

We just need the mod maker to work on that BBC bug.

Freddy

Just to be going on with.  If you want to block out chopped urls then try this out :

Before :

// Generate the pop up...
$popup = NiceTooltip($w['preview'], $w['subject']);


Add :    

// Quick fix for chopped urls...
$bad_url = strpos($w['preview'],'[url=');

if ($bad_url)
$w['preview'] = substr($w['preview'], 0, $bad_url);


It's only rough and ready but that should get most of them I think.  I can't figure out a simple way to check for broken bbc code, I would rather let the mod maker work on that bug.