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, 06:04:11 AM

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

Author Topic: Latest shout block  (Read 26145 times)

0 Members and 1 Guest are viewing this topic.

Offline bloc

  • Founder
  • *
  • Posts: 5229
    • Bloc
Latest shout block
« on: October 15, 2005, 03:18:11 AM »
If you need to display the latest shout..use this code:

Code: [Select]
  
global $settings;

$tp_prefix = $settings['tp_prefix'];
  
   $request = db_query("SELECT * FROM {$tp_prefix}shoutbox WHERE type='shoutbox'  ORDER BY value2 DESC LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
{
  $shouts='';
  while($row = mysql_fetch_assoc($request)){
  $shouts .= doUBBC($row['value1'],true);
  $shouts .='<br /> by <b>'.$row['value3'].'</b> on '.timeformat($row['value2']).'<br />';
  }
  echo $shouts;
  mysql_free_result($request);
}

It will also allow more than 1 shout, simply change the "limit 1" to you preferred number ("limit 5" for example), and maybe add some limiters to the html code.

--edited 29/3/07---
Edited code to reflect the table that was renamed in TP 0.9.8
« Last Edit: March 29, 2007, 04:29:17 PM by IchBinâ„¢ »

WizardHawk

  • Guest
Re: Latest shout block
« Reply #1 on: October 15, 2005, 07:59:09 AM »
You rock Bloc! Exactly what I wanted.  ;)

Now I can show the last two shouts in a center block. Works well.

eldacar

  • Guest
Re: Latest shout block
« Reply #2 on: October 17, 2005, 08:38:44 PM »
Hmm could this be used to show the latest 5 for example, and then have the latest 20 when you click the title? That would be good, instead of how it is now when the same number are shown in both places.

WizardHawk

  • Guest
Re: Latest shout block
« Reply #3 on: October 18, 2005, 01:42:58 AM »
Not sure what you are asking him to do here. With the above code you can show the last n number of shouts. You can show 1, or as many as you like. It isn't set by the same number as the number of shouts to remember in the actual shoutbox area.

On my board, the shoutbox holds the last 15 shouts and my latest shout block displays the last two of them. A guest can only view shouts so they can see the last two and if they click a link I have in the content bar they can view the full 15 in the list but cannot add new ones. Users can click the link in content and see the full list + add new shouts plus there is a small shoutbox block in use on the right side bar (most users keep this bar closed).

If you want the latest shout block to not only show a few, but link back to the full list, you will have to add a link yourself. The URL to have the full box displayed is (your site)/index.php?action=tpmod&sub=shoutbox

Using that URL will bring up the shoutbox full screen and show however many you have set for the shoutbox.

Sakuragi

  • Guest
Re: Latest shout block
« Reply #4 on: October 18, 2005, 10:16:48 PM »
i would like to show the last shout on the header, so when o i put this code on index.template.php i got this error:
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in .../Themes/TP_techhead11rc1/index.template.php on line 354


line 354: $tp_prefix = 'tportal_';

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Latest shout block
« Reply #5 on: October 18, 2005, 10:43:12 PM »
Can you post the whole code that you put in?

Sakuragi

  • Guest
Re: Latest shout block
« Reply #6 on: October 19, 2005, 06:14:25 AM »
Code: [Select]
<!-- begin shoutbox -->

<tr align="left">
  <td>  
    <table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
      <tr>
<td width="100%" valign="bottom">
$tp_prefix = 'tportal_';
   
   $request = db_query("SELECT * FROM {$tp_prefix}variables WHERE type='shoutbox'  ORDER BY value2 DESC LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
{
  $shouts='';
  while($row = mysql_fetch_assoc($request)){
  $shouts .= tp_doUBBC($row['value1'],true);
  $shouts .='<br /> by <b>'.$row['value3'].'</b> on '.timeformat($row['value2']).'<br />';
  }
  echo $shouts;
  mysql_free_result($request);
}
</td>
      </tr>
    </table>         
  </td>
</tr>

<!-- end shoutbox -->

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Latest shout block
« Reply #7 on: October 19, 2005, 06:33:34 AM »
I'm not a fluent coder by any means, but I think you're missing a couple of things.
I'm not sure what exactly you have above and below that. But you need to have echo statements if that is a php file. It should look something like this.


Code: [Select]
<!-- begin shoutbox -->

echo ' <tr align="left">
  <td>  
    <table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
      <tr>
<td width="100%" valign="bottom">';
$tp_prefix = 'tportal_';
   
   $request = db_query("SELECT * FROM {$tp_prefix}variables WHERE type='shoutbox'  ORDER BY value2 DESC LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
{
  $shouts='';
  while($row = mysql_fetch_assoc($request)){
  $shouts .= tp_doUBBC($row['value1'],true);
  $shouts .='<br /> by <b>'.$row['value3'].'</b> on '.timeformat($row['value2']).'<br />';
  }
  echo $shouts;
  mysql_free_result($request);
}
echo '       </td>
      </tr>
    </table>         
  </td>
</tr>';

<!-- end shoutbox -->


Sakuragi

  • Guest
Re: Latest shout block
« Reply #8 on: October 19, 2005, 07:10:19 AM »
my index.template.php:

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Latest shout block
« Reply #9 on: October 19, 2005, 07:57:26 AM »
I fixed your errors in the file and I'll attach the new one here. I don't think you have your HTML right though. Do you know how to do html? You may want to change your shoutbox to this:
Code: [Select]
<!-- begin shoutbox -->
         echo ' <table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
              <tr>
                <td width="100%" valign="bottom">';
                $tp_prefix = 'tportal_';

           $request = db_query("SELECT * FROM {$tp_prefix}variables WHERE type='shoutbox'  ORDER BY value2 DESC LIMIT 1", __FILE__, __LINE__);
                if (mysql_num_rows($request) > 0)
                {
                  $shouts='';
                  while($row = mysql_fetch_assoc($request)){
                                  $shouts .= tp_doUBBC($row['value1'],true);
                                  $shouts .='<br /> by <b>'.$row['value3'].'</b> on '.timeformat($row['value2']).'<br />';
                  }
                  echo $shouts;
                  mysql_free_result($request);
                }
               echo '
                </td>
              </tr>
            </table>';

<!-- end shoutbox -->