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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 567
  • Total: 567

Tricky Block Request

Started by Xarcell, June 01, 2006, 04:18:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JPDeni

Don't feel bad. :) It's okay. I just get confused when I have to go from one thing to another in order to figure out what somebody wants. I need it all in one place. Like my sig file says "Explain it to me like I was a three-year-old." ;)

That shouldn't be too much. I'll see if I can get it out today.

Madisonianne

 :uglystupid2:  I should know how it is - I do lots of tech support and I know how hard it is when people are all over the map trying to explain...

I've been trying to do this without asking for help - there is already SO much out here that I've not really needed - so I really appreciate that I get a response when I do finally ask!  You so rock!  (Actually, Tiny Portal does, too...things have gotten so much easier since I switched to TP!)

JPDeni

TP is wonderful. That's why I give support here now. The script has done a lot for me and this is my way of giving back.

I understand about being a tech support person, though. I sometimes don't ask questions the way I should when I need help either. :)

Okay. This should do it, if I understand what you wanted:


global $db_prefix, $scripturl;

$board = 5;              // Set number of the board here
$number_to_display = 10; // You can change the number of topics that are displayed
$date_format = "j M Y";  // For displaying the date

// Links to first post in topic
// Order by the date of the first post in the topic
// List date topic was started
//////////////////////////////////////////////////////////////////////////////////
require_once("Subs.php");

$result = db_query("
SELECT m.ID_TOPIC, m.posterTime, m.subject, m.posterName, m.ID_MEMBER, t.ID_LAST_MSG
FROM {$db_prefix}topics as t, {$db_prefix}messages as m
WHERE t.ID_BOARD = $board
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_FIRST_MSG DESC
LIMIT 10", __FILE__, __LINE__);

echo '<table>';
echo '<tr><td>Subject</td><td>Started by</td><td>Date</td></tr>';
while ($row = mysql_fetch_assoc($result)){
echo '<tr>';
echo '<td><a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '">'  . $row['subject'] . '</a></td>'; // Link to first message in topic
echo '<td><a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'; // Started by
echo '<td>' . date($date_format,$row['posterTime']) . '</td>';
echo '<tr>';
}
mysql_free_result($result);

Madisonianne

Argh!  My internet was down for hours but I'm back now and will give it a try and let you know how it goes.  No matter what, I very much appreciate all you've done!!!

Madisonianne

#54
How did you do that!?!  LOL  I love it!  Now all I need to know is if I can add more boards to it...if not, I'll work it out but just had to ask. 


Thank you so much - this is great!

(((I'm realizing I said what I wanted wrong (need a whole category or multiple boards), but this is great so thank you again!)))

JPDeni

:) I've been doing this for a while. I still make a lot of mistakes, but this sort of thing is pretty straightforward.

There's different coding for a whole category or for different boards. This will give you different boards, but not necessarily all the boards in a given category. Put the board numbers into the $board array.


global $db_prefix, $scripturl;

$board = array(5,6,15);              // Set numbers of the boards here
$number_to_display = 10; // You can change the number of topics that are displayed
$date_format = "j M Y";  // For displaying the date

// Links to first post in topic
// Order by the date of the first post in the topic
// List date topic was started
//////////////////////////////////////////////////////////////////////////////////
require_once("Subs.php");

$where = '(t.ID_BOARD= ' . implode(' OR t.ID_BOARD=',$board) . ')';

$result = db_query("
SELECT m.ID_TOPIC, m.posterTime, m.subject, m.posterName, m.ID_MEMBER, t.ID_LAST_MSG
FROM {$db_prefix}topics as t, {$db_prefix}messages as m
WHERE $where
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_FIRST_MSG DESC
LIMIT 10", __FILE__, __LINE__);

echo '<table>';
echo '<tr><td>Subject</td><td>Started by</td><td>Date</td></tr>';
while ($row = mysql_fetch_assoc($result)){
echo '<tr>';
echo '<td><a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '">'  . $row['subject'] . '</a></td>'; // Link to first message in topic
echo '<td><a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'; // Started by
echo '<td>' . date($date_format,$row['posterTime']) . '</td>';
echo '<tr>';
}
mysql_free_result($result);


This does not check to be sure that the person is allowed to read that board. You'll have to take care of that yourself with block permissions, in case there are boards that you don't want everyone to see.

Madisonianne

This is it - with all the right information in all the right places!  Now the only problem is that it's including the blocks around it for some reason  - I have no idea how that's happening!  Here's a screen shot:


JPDeni

The upper part is the code I wrote. What else do you have in that block? It looks like you somehow have a block within a block. This should go into a php block by itself.

Madisonianne

Yes, the top part is what you wrote...And yes, it's in a separate block.  When I move the block from left to right to center - up or down - the same thing happens with the adjacent block.    This could only happen to me, I tell ya!  LOL

JPDeni

It's my mistake. I forgot the closing table tag.

After

echo '<td>' . date($date_format,$row['posterTime']) . '</td>';
echo '<tr>';
}


add


echo '</table>';


(Actually, it was there originally, but it got deleted as I was debugging and I didn't get it back.)

This website is proudly hosted on Crocweb Cloud Website Hosting.