Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

August 19, 2022, 08:24:47 PM

Login with username, password and session length
Members
  • Total Members: 3843
  • Latest: Tricky
Stats
  • Total Posts: 193479
  • Total Topics: 21088
  • Online today: 60
  • Online ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 0
Guests: 49
Total: 49

Author Topic: [Discussion] Recent TOPICS scrolling with hover over previews.  (Read 25628 times)

0 Members and 1 Guest are viewing this topic.

prometheus fire

  • Guest
[Discussion] Recent TOPICS scrolling with hover over previews.
« on: January 02, 2010, 07:09:26 PM »
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.
« Last Edit: January 03, 2010, 10:03:08 AM by freddy888 »

prometheus fire

  • Guest
Re: Re: [Discussion] Recent TOPICS scrolling with hover over previews.
« Reply #1 on: January 02, 2010, 07:41:50 PM »
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)
Code: [Select]
// Recent post list:   [board] Subject by Poster Date
function ssi_recentPosts($num_recent = 8, $exclude_boards = null, $output_method = 'echo')

and, for recent topics:
Code: [Select]
// 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.
« Last Edit: January 02, 2010, 08:24:47 PM by freddy888 »

Offline Freddy

  • Moderator
  • *
  • Posts: 1615
    • AiDreams
Re: Re: [Discussion] Recent TOPICS scrolling with hover over previews.
« Reply #2 on: January 02, 2010, 08:08:17 PM »
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.
« Last Edit: January 02, 2010, 08:25:04 PM by freddy888 »

Offline Freddy

  • Moderator
  • *
  • Posts: 1615
    • AiDreams
Re: Re: [Discussion] Recent TOPICS scrolling with hover over previews.
« Reply #3 on: January 02, 2010, 08:15:45 PM »
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

  • Guest
Re: Re: [Discussion] Recent TOPICS scrolling with hover over previews.
« Reply #4 on: January 02, 2010, 08:21:54 PM »
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:
Code: [Select]
// 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:
Code: [Select]
// 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.
« Last Edit: January 02, 2010, 08:50:49 PM by prometheus fire »

Offline Freddy

  • Moderator
  • *
  • Posts: 1615
    • AiDreams
Re: Re: [Discussion] Recent TOPICS scrolling with hover over previews.
« Reply #5 on: January 02, 2010, 08:29:45 PM »
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.
« Last Edit: January 02, 2010, 08:33:23 PM by freddy888 »

Offline Freddy

  • Moderator
  • *
  • Posts: 1615
    • AiDreams
Re: [Discussion] Recent TOPICS scrolling with hover over previews.
« Reply #6 on: January 02, 2010, 09:03:54 PM »
Try changing the query to this :

Code: [Select]
$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 :)
« Last Edit: January 02, 2010, 09:28:56 PM by freddy888 »

prometheus fire

  • Guest
Re: [Discussion] Recent TOPICS scrolling with hover over previews.
« Reply #7 on: January 03, 2010, 09:20:14 AM »
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
« Last Edit: January 03, 2010, 09:24:35 AM by prometheus fire »

Offline Freddy

  • Moderator
  • *
  • Posts: 1615
    • AiDreams
Re: [Discussion] Recent TOPICS scrolling with hover over previews.
« Reply #8 on: January 03, 2010, 10:09:37 AM »
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.
« Last Edit: January 03, 2010, 10:17:56 AM by freddy888 »

Offline Freddy

  • Moderator
  • *
  • Posts: 1615
    • AiDreams
Re: [Discussion] Recent TOPICS scrolling with hover over previews.
« Reply #9 on: January 03, 2010, 10:42:00 AM »
Just to be going on with.  If you want to block out chopped urls then try this out :

Before :

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

Add :    

Code: [Select]
// 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.
« Last Edit: January 03, 2010, 10:43:44 AM by freddy888 »