News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

display avy in ssi_boardNews

Started by diplomat., January 06, 2005, 05:21:31 PM

Previous topic - Next topic

[SiNaN]

Are you sure you made the needed change in the code that akabugeyes gave correctly?
Former SMF Core Developer | My Mods | SimplePortal

myaicons

yup... im pretty sure i did... i just double checked it.... (its all only in the ssi.php right?)

i scratch your back you scratch my back...
funny thing about my back is its located on my...

ApocalypticSpirit

Sorry to dig up an old thread again, but I've tried to apply this on a 1.1.4 board and there is no image loading at all.

I've just recently been experimenting with SSI so I could have placed something wrong :P
<?php
ob_start
();
?>

QuoteSite Stuff
<?

require("forum/SSI.php");

   $array = ssi_boardNews(15.0, 5, null, 250, 'array');

   foreach ($array as $news)
   
   {
      echo '
  <div style="background-color:#999999; width:564px; height:auto; border:1px solid #000000;">
         <table border="0" width="100%" align="center" class="ssi_table" cellspacing="5">
            <tr>
               <td width="50px" height="50px">
<img src="', $news['avatar']['href'], '" width="50" height="50" />
               </td>
               <td align="left" width="100%">
               <small>', $news['time'], '</small><br />
   <b><font size="3" color="#cccccc">', $news['subject'], '</font></b><br />
   <small>Posted by: ', $news['poster']['name'], '</small><br />
      </td>
            </tr>
            <tr>
              <td align="left" colspan="2"><hr align="left" width="50%" /></td>
            </tr>
            <tr>
               <td align="left" colspan="2">', $news['body'], '<br /><br /></td>
            </tr>
<tr>
               <td align="left" colspan="2"><a href="', $news['href'], '">Comment</a><br /><br /></td>
            </tr>
         </table>
</div>
         ';

      if (!$news['is_last'])
         echo '
         <hr width="100%" />
         ';
   }

?>

QuoteMore Site Stuff

ApocalypticSpirit

Sorry if i'm seeming pushy but we really need this fix, then we can launch the site :)

Here's the ssi_boardNews part of the SSI also.

// Show the latest news, with a template... by board.
function ssi_boardNews($board = null, $limit = null, $start = null, $length = null, $output_method = 'echo')
{
global $scripturl, $db_prefix, $txt, $settings, $modSettings, $context;
global $func;

loadLanguage('Stats');

// Must be integers....
if ($limit === null)
$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
else
$limit = (int) $limit;

if ($start === null)
$start = isset($_GET['start']) ? (int) $_GET['start'] : 0;
else
$start = (int) $start;

if ($board !== null)
$board = (int) $board;
elseif (isset($_GET['board']))
$board = (int) $_GET['board'];

if ($length === null)
$length = isset($_GET['length']) ? (int) $_GET['length'] : 0;
else
$length = (int) $length;

$limit = max(0, $limit);
$start = max(0, $start);

// Make sure guests can see this board.
$request = db_query("
SELECT ID_BOARD
FROM {$db_prefix}boards
WHERE " . ($board === null ? '' : "ID_BOARD = $board
AND ") . "FIND_IN_SET(-1, memberGroups)
LIMIT 1", __FILE__, __LINE__);
if (mysql_num_rows($request) == 0)
{
if ($output_method == 'echo')
die($txt['smf_news_error2']);
else
return array();
}
list ($board) = mysql_fetch_row($request);
mysql_free_result($request);

// Load the message icons - the usual suspects.
$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find the post ids.
$request = db_query("
SELECT ID_FIRST_MSG
FROM {$db_prefix}topics
WHERE ID_BOARD = $board
ORDER BY ID_FIRST_MSG DESC
LIMIT $start, $limit", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
$posts[] = $row['ID_FIRST_MSG'];
mysql_free_result($request);

if (empty($posts))
return array();

// Find the posts.
$request = db_query("
SELECT
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName, m.posterTime,
t.numReplies, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled, m.ID_MSG, t.locked, mem.avatar, a.ID_ATTACH, a.attachmentType, a.filename
FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = m.ID_MEMBER)
WHERE t.ID_FIRST_MSG IN (" . implode(', ', $posts) . ")
AND m.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_FIRST_MSG DESC
LIMIT " . count($posts), __FILE__, __LINE__);
$return = array();
while ($row = mysql_fetch_assoc($request))
{
// If we want to limit the length of the post.
if (!empty($length) && $func['strlen']($row['body']) > $length)
{
$row['body'] = $func['substr']($row['body'], 0, $length);

// The first space or line break. (<br />, etc.)
$cutoff = max(strrpos($row['body'], ' '), strrpos($row['body'], '<'));

if ($cutoff !== false)
$row['body'] = $func['substr']($row['body'], 0, $cutoff);
$row['body'] .= '...';
}

$row['body'] = parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']);

      if (stristr($row['avatar'], 'http://') && !empty($modSettings['avatar_check_size']))
      {
         $sizes = url_image_size($row['avatar']);

         // Does your avatar still fit the maximum size?
         if ($modSettings['avatar_action_too_large'] == 'option_refuse' && is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external']))))
         {
            // Fix it permanently!
            $row['avatar'] = '';
            updateMemberData($row['ID_MEMBER'], array('avatar' => '\'\''));
         }
      }

// Check that this message icon is there...
if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

censorText($row['subject']);
censorText($row['body']);

$return[] = array(
'id' => $row['ID_TOPIC'],
'message_id' => $row['ID_MSG'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
'subject' => $row['subject'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'body' => $row['body'],
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['numReplies'] . ' ' . ($row['numReplies'] == 1 ? $txt['smf_news_1'] : $txt['smf_news_2']) . '</a>',
'replies' => $row['numReplies'],
'comment_href' => !empty($row['locked']) ? '' : $scripturl . '?action=post;topic=' . $row['ID_TOPIC'] . '.' . $row['numReplies'] . ';num_replies=' . $row['numReplies'],
'comment_link' => !empty($row['locked']) ? '' : '<a href="' . $scripturl . '?action=post;topic=' . $row['ID_TOPIC'] . '.' . $row['numReplies'] . ';num_replies=' . $row['numReplies'] . '">' . $txt['smf_news_3'] . '</a>',
'new_comment' => !empty($row['locked']) ? '' : '<a href="' . $scripturl . '?action=post;topic=' . $row['ID_TOPIC'] . '.' . $row['numReplies'] . '">' . $txt['smf_news_3'] . '</a>',
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => !empty($row['ID_MEMBER']) ? $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] : '',
'link' => !empty($row['ID_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>' : $row['posterName']
),
'locked' => !empty($row['locked']),
'is_last' => false
);
}
mysql_free_result($request);

if (empty($return))
return $return;

$return[count($return) - 1]['is_last'] = true;

if ($output_method != 'echo')
return $return;

foreach ($return as $news)
{
echo '
<div>
<a href="', $news['href'], '">', $news['icon'], '</a> <b>', $news['subject'], '</b>
<div class="smaller">', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], '</div>

<div class="post" style="padding: 2ex 0;">', $news['body'], '</div>

', $news['link'], $news['locked'] ? '' : ' | ' . $news['comment_link'], '
</div>';

if (!$news['is_last'])
echo '
<hr style="margin: 2ex 0;" width="100%" />';
}
}

[SiNaN]

You didn't make the last edit, check it again.
Former SMF Core Developer | My Mods | SimplePortal

Gambi

Hi, is there a way to get this to work with comments? I'm using the replies from a thread via SSI.php to look like comments on the mainpage and they already look good but I would like to add the user's avatar next to their name. I'm sure it shouldn't be too difficult but I cannot find the right avatar string for it. I'm using 1.1.5 and here is the code for my page.

<img src="images/division.PNG" width="780" height="11">

      <table width="700" border="0">
        <tr>
          <td><img src="images/news_head.png" width="457" height="110"></td>
          <td><img src="images/iaad.gif" width="334" height="109"></td>
        </tr>
      </table>
      </p>
      </td>
  </tr>
  <tr> <img src="images/division.PNG" width="800" height="11">

<?php
// Require SSI
require('/home/content/B/l/a/Blackthorne519/html/forum/SSI.php');

// No topic? That's bad
if (empty($_REQUEST['topic']))
die('No topic passed');

// Get this topic and its replies
$return ssi_topic($_REQUEST['topic'], nullnull'array'); // Setting something to 'null' will use the default value.

// Output the first post
echo '
<div>
<h3><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="36"><font style="text-transform: uppercase;">'
$return['icon'], '</font></td>
<td><font style="text-transform: uppercase;"><b>'
$return['subject'], ' </b> </font><br>

<i>'
$return['time'], ' by '$return['poster']['link'], '</i></td>
</tr>
</table>


<div class="post" style="padding: 2ex 0;">'
$return['body'], '</div>

'
$return['locked'] ? '' $return['link'], '<br /><br />
</div>

<h3><font style="text-transform: uppercase;"><b>'
$txt['ssiTopic_replies'], '</font></b></h3><br>

'
$return['pageindex'];
echo 
'<br><br>';
// Loop through each post
foreach ($return['replies'] as $post)
{
echo '
<h2><div>
<div><font style="text-transform: uppercase;"><b><img src="(users avatar)" width="30" height="30" align="left" hspace="3" border="1" />'
$post['poster']['link'], '</font></b> <br><i> '$post['time'], '</i></div>

<div class="post" style="padding: 2ex 0;">'
$post['body'], '</div>
</div>'
;

// The last post? Let's put the page numbers
if ($post['is_last'])
echo '
</h2>'
$return['pageindex'];
else
echo '
'
;
}
?>


   <br> <td><img src="images/bottom.PNG" width="800" height="67"></td>


Thanks!


[SiNaN]

What do you mean by comments? Can you post your ssi_topic function here?
Former SMF Core Developer | My Mods | SimplePortal

Advertisement: