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: 561
  • Total: 561

custom "Recent Topics from Board X, Y, Z only" php block

Started by iowamf, November 04, 2005, 09:47:16 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

JPDeni

I see. You want the second line to be indented.

This should do it. You'll need to enter the names of the boards.


global $context, $scripturl;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

// Enter the names of the boards you want to display, along with their numbers
$board[26] = 'Name of board 26';
$board[25] = 'Name of board 25';
$board[24] = 'Name of board 24';

$new_row = 1;
echo '<table border="0" width="100%" id="table1" cellpadding="2" style="border-collapse: collapse">';

foreach ($board as $name => $key) {
if ($new_row == 1)
echo '<tr>';
echo '
<td style="display: block; margin-left: 2em; text-indent: -2em;">' . $key . '<br />';
$result=ssi_recentTopics_NEW(10,array($key),'return');
foreach($result as $my){

echo '
<span class="smalltext3">
<img src="'.$settings['images_url'].'/TPdivider3.gif" alt="" border="0" style="margin:0 2px 0 0;" />
<&nbsp;>' . $my['link'] . '</span>
<br>';
}
echo'
</td>';
if ($new_row == 3) {
echo '</tr>';
$new_row = 0;
}
++$new_row;
}

echo '</table>';


If the indenting isn't right, you'll want to change this line:


<td style="display: block; margin-left: 2em; text-indent: -2em;">' . $key . '<br />';


If the indenting is too much, change the 2 to 1. If it's not enough, change the 2 to 3 or 4 (or whatever works).

alhaudhie

when i enable block that contain this new code... i cant log in / see frontage of my site.. but can in forum. tq

JPDeni

Then there's an error somewhere. Can I see the page?

alhaudhie

Quote from: JPDeni on September 30, 2009, 07:35:25 PM
Then there's an error somewhere. Can I see the page?

There is nothing... it make long time to loading... but when the web appear it reset the login to guest automatically... registered user cant see it.  also to  guest.

JPDeni

I need to have the URL to the page. Even though nothing may appear on the page, I might be able to get something from the source code.

Otherwise, you'll just have to take the code out and forget it, because I don't know what's wrong with it.

alhaudhie


im not already yet to full open.
but if i enable to guest.. there is Internet Explorer cannot display the webpage
 
  Most likely causes:
You are not connected to the Internet.
The website is encountering problems.
There might be a typing error in the address.


JPDeni

Then I suggest that you remove the code. I don't see what the problem is and I can't test this code on my own site.

Renegd98

any idea why when i use this code it puts [/url] on the end?

It outputs this:
mpinones wishes to join -=NoBS=-[/url]

Code I am using:

global $context, $scripturl, $settings, $txt;
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$result=ssi_recentTopics_Include(10,array(35),'return');

foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];

  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
        echo ' <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo '<br />';

}
echo '</span>';

Freddy

This example post originates from a form or something ?

I can't see why it would do that with the code you posted, perhaps it is introduced earlier.

K-teto

Hi guys.

I've been using this slightly modified version of the code:
global $context, $scripturl, $settings, $txt;

//define the two images for read/unread replies
$bullet = '<img src="'.$settings['images_url'].'/TPdivider5.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$bullet2 = '<img src="'.$settings['images_url'].'/TPdivider4.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

$result=ssi_recentTopics_Include(4,array(34),'return');
// show the board name
echo '<span class="smalltext"><b><a href="http://www.bjdoll.net/index.php?board=34.0">Newsposters</a>:</b><br /></span>';
// and now, the latests posts
foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];

  // is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
        echo ' <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['new_from'], '#new"></a>';
echo '<br />';

}
echo '</span>';

With some tables, I've got a nice looking recent posts block, conveniently sorted for the forum users.

It outputs something like this:

You can see it working at http://www.bjdoll.net
The darker bullets are for the unread replies, and the lighter ones, for... well, for the read ones  ;D

But now, some people are asking for more info about the threads showing in the front page, so... here is the question.
Does anyone know how to add the number of posts of the threads and the name of the last poster?
Something like this:
Ã,·Thread name [number of posts](last poster's name)

Any help will be greatly appreciated, this code has been of great help for my site.

This website is proudly hosted on Crocweb Cloud Website Hosting.