News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Showing Attached Topic images in ssi_boardnews

Started by ModelitMatt, February 04, 2011, 03:18:57 AM

Previous topic - Next topic

ModelitMatt

I have recently installed this mod:
http://custom.simplemachines.org/mods/index.php?mod=1151

I was wondering does anyone know how to show the attached image in the ssi_boardnews script so when it's setup to post new topics on the front page, if the image is attached it shows it.

Here is an example of what I am using for ssi_boardnews now.


<table width="595" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="29"><div id="article-body-t"></div>
      <div id="article-body-m">', $news['icon'], ' <a href="', $news['href'], '">', $news['subject'], '</a></div></td>
  </tr>
</table>
<table width="595" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><div id="articles">
      <div id="article-body-c">
        <table width="595" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="595"><table width="595" border="0" cellspacing="0" cellpadding="9">
                <tr>
                  <td width="149" height="290" valign="top">Posted: ', $news['time'] , '<br>
                    <br>
                    Posted by:', '<br>
                    ', $news['poster']['link'], '</td>
                  <td width="410">', $context['show_thumbnails'] ? 3 : 2 ,'</td>
                </tr>
              </table></td>
          </tr>
          <tr>
            <td height="32" bgcolor="#002035" align="right" style="padding-right: 10px;">', $news['link'], $news['locked'] ? '' : ' - ' . $news['comment_link'], '</td>
          </tr>
          <tr>
            <td height="5"></td>
          </tr>
        </table>
      </div>
      <div id="article-body-d"></div></td>
  </tr>
</table>
</div>


Currently its just spitting out the number two when using this code
', $context['show_thumbnails'] ? 3 : 2 ,'

But it does work where the mod was supposed to put it after an image is attached.

Any assistance is greatly appreciated.

Example of page:
http://goo.gl/M1id2 (short temporary url) - index.php page
http://goo.gl/d0EZI (short temporary url) - articles (smf topic index)

If short url's are un-acceptable just let me know and I'll post full I just don't wish SEO to pickup the trail of the test folder.

I've attached a screenshot of how I'd like it to work.

ModelitMatt

#1
 :o My apologies for the bump, I'm still attempting to find the resolution to this situation.
http://goo.gl/BL0qj - (short temporary url) - General Discussion (smf board index)

If you need the full URL i can provide it but I would rather send it as a message so SEO doesn't pick it up off the forum.

Kays

For something like that you might be best to contact the mod author as I suspect additional code might be needed in SSI.php to make it work.

Do however look at this mod. It might do what you wish.

http://custom.simplemachines.org/mods/index.php?mod=2280

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

ModelitMatt

I don't believe it requires adjustments to the mod I'm sure the scripts available in the mod though.
The link you supplied me I took a try at that mod

Sadly I'm not setting it up right or its not working properly on the version of SMF i'm using.

Added above
$parameters = array(
  'limit' => 15,
  'board' => array(1,2),
  'category' => array(12),
  'board_disp' => true,
  'category_disp' => true,
  'avatar' => 'left',
  'icon' => 'thumbup',
  'attachments' => 'inline'
 
 
);
ssi_multiBoardNews($parameters);


Added

', $parameters['attachments'], '

But it echos the word inline, I'm guessing I setup the script incorrectly, if you know what I've done wrong I'd appreciate your input.

Kays

I've not really looked at that mod closely. But if you look at the html for that function, it is setup to display attachments.

The best place for support on this is the support topic for the mod.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

ModelitMatt

I feel if I contact the mod developer it will get ignored as a lot of people would ask about their code to the point they would just get fed up.

A programmer told me I should attempt trying directly through MYSQL Query so I may choose to do that as I don't see any other ways other than waiting for replies which my time limitations can't afford.

Arantor

There's only one reason I can think of why the code you posted fails to show attachments... that's if attachments being shown to guests is disabled.

* Arantor originally wrote that mod ;)

ModelitMatt

Quoteattachments being shown to guests is disabled.

I wish that were the case, but if that were true then I couldn't see them here:
http://modelitup.com/articles/index.php?topic=5.msg7#new

Congrad's on building the mod, I figure I may be installing it or using it incorrectly?
I've installed it and went over it with the parsed info.

Arantor


ModelitMatt

Quote from: Arantor on February 06, 2011, 05:49:20 PM
OK so where's the page you're putting this on?

I tried placing the script in the SSI.php file within the echo of the ssi_boardnews function.

After that didn't show the image I tried it on my index.php file and that wouldn't work either for me.

I have the links added above i you wanted to see what it looks like.
If you want the full URL of the short links I can send it to you over PM just ask and I'll send them.

Arantor

If you put that inside ssi_boardnews... it's not going to work properly if at all.

Basically you just need the SSI include and the above code... if you're putting it anywhere else there's a good chance it'll screw up... where EXACTLY is the code now? Any chance you can attach the file here?

ModelitMatt

#11
for SSI.php your mod was added just before

?>


This is what was added:
// Arantor: ssi_multiBoardNews
function ssi_multiBoardNews($parameters)
{
global $scripturl, $db_prefix, $txt, $settings, $modSettings, $context, $smcFunc, $user_profile;

loadLanguage('Stats');

// 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';

$feed_types = array('rss', 'rdf', 'atom', 'none');
$attach_types = array('none', 'linkonly', 'thumbnail', 'inline');
$avatar_types = array('none', 'left', 'right');

// Checking off the parameters first
$parameters['limit'] = isset($parameters['limit']) ? max(1, (int) $parameters['limit']) : 5;
$parameters['start'] = isset($parameters['start']) ? max(0, (int) $parameters['start']) : 0;
$parameters['length'] = isset($parameters['length']) ? (int) $parameters['length'] : 0;
$parameters['perms_override'] = isset($parameters['perms_override']) ? (bool) $parameters['perms_override'] : false;
$parameters['attachments'] = isset($parameters['attachments']) ? (in_array($parameters['attachments'], $attach_types) ? $parameters['attachments'] : 'none') : 'none';
$parameters['avatar'] = isset($parameters['avatar']) ? (in_array($parameters['avatar'], $avatar_types) ? $parameters['avatar'] : 'none') : 'none';

$parameters['feed'] = isset($parameters['feed']) ? (array) $parameters['feed'] : array('none');
$parameters['feed'] = array_intersect($parameters['feed'], $feed_types);
if (count($parameters['feed']) == 0)
$parameters['feed'] = array('none');

$parameters['board'] = isset($parameters['board']) ? (array) $parameters['board'] : array(0);
$parameters['category'] = isset($parameters['category']) ? (array) $parameters['category'] : array(0);
$parameters['board_disp'] = isset($parameters['board_disp']) ? (bool) $parameters['board_disp'] : true;
$parameters['category_disp'] = isset($parameters['category_disp']) ? (bool) $parameters['category_disp'] : false;

$parameters['icon'] = isset($parameters['icon']) ? (array) $parameters['icon'] : array();
$parameters['icon'] = array_intersect(array_unique($parameters['icon']), $stable_icons);

$parameters['output_type'] = isset($parameters['output_type']) ? ($parameters['output_type'] == 'echo' ? 'echo' : 'array') : 'echo';

foreach ($parameters['board'] as $key => $value)
{
$value = (int) $value;
if ($value < 1)
unset ($parameters['board'][$key]);
else
$parameters['board'][$key] = (int) $value;
}

if (!empty($parameters['category']))
{
$parameters['category'] = array_unique((array) $parameters['category']);
foreach ($parameters['category'] as $key => $value)
{
$value = (int) $value;
if ($value < 1)
unset ($parameters['category'][$key]);
else
$parameters['category'][$key] = (int) $value;
}

if (count($parameters['category']) > 0)
{
$query = $smcFunc['db_query']('', '
SELECT id_board FROM {db_prefix}boards WHERE id_cat IN ({array_int:cat_list})',
array(
'cat_list' => $parameters['category'],
)
);
while($row = $smcFunc['db_fetch_row']($query))
$parameters['board'][] = $row[0];

$smcFunc['db_free_result']($query);
}
}

$parameters['board'] = array_unique($parameters['board']);

if (count($parameters['board']) == 0)
$parameters['board'] = array(0);

if (!$parameters['perms_override'])
{
// So we're checking the guest perms here. Note this can only be done from a PHP call.
// You can't do this from an external SSI type include (via $_GET) for obvious reasons!

$board_count = count($parameters['board']);

$board_limit = 1;
$where = 'FIND_IN_SET(-1, member_groups)';
if ($board_count > 1)
{
$where = 'id_board IN ({array_int:board_list}) AND ' . $where;
$board_limit = $board_count;
}

// So, either get all boards we asked for and check their membergroups,
// or we asked for nothing, so get the first board you find that is guest safe

$request = $smcFunc['db_query']('', '
SELECT id_board
FROM {db_prefix}boards
WHERE ' . $where . '
LIMIT {int:limit}',
array(
'board_list' => $parameters['board'],
'limit' => $board_limit,
)
);
if ($smcFunc['db_num_rows']($request) == 0)
{
if ($output_method == 'echo')
die($txt['ssi_no_guests']);
else
return array();
}

$allowed_boards = array();
while($row = $smcFunc['db_fetch_row']($request))
$allowed_boards[] = $row[0];
$smcFunc['db_free_result']($request);

if ($board_count > 0)
$parameters['board'] = array_intersect($parameters['board'], $allowed_boards);
else
$parameters['board'] = $allowed_boards;

if (count($parameters['board']) == 0)
$parameters['board'] = array(0);
}

// Find the post ids.
$request = $smcFunc['db_query']('', '
SELECT id_first_msg, icon
FROM {db_prefix}topics AS t INNER JOIN {db_prefix}messages AS m ON (t.id_first_msg = m.id_msg)
WHERE t.id_board IN ({array_int:board_list})' . (count($parameters['icon']) > 0 ? '
AND m.icon IN ({array_string:icon})' : '') . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}' : '') . '
ORDER BY id_first_msg DESC
LIMIT ' . $parameters['start'] . ', ' . $parameters['limit'],
array(
'board_list' => $parameters['board'],
'is_approved' => 1,
'icon' => $parameters['icon'],
)
);

$posts = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$posts[] = $row['id_first_msg'];
$smcFunc['db_free_result']($request);

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

// Find the posts.
$request = $smcFunc['db_query']('', '
SELECT
m.icon, m.subject, m.body, IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time,
t.num_replies, t.id_topic, m.id_member, m.smileys_enabled, m.id_msg, t.locked, t.id_board, b.name AS board_name, c.id_cat, c.name AS cat_name
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
INNER JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board)
INNER JOIN {db_prefix}categories AS c ON (b.id_cat = c.id_cat)
WHERE t.id_first_msg IN ({array_int:post_list})
ORDER BY t.id_first_msg DESC
LIMIT ' . count($posts),
array(
'post_list' => $posts,
)
);
$return = array();
$posters = array();
$messages = array();
$last = 0;
while ($row = $smcFunc['db_fetch_assoc']($request))
{
// If we want to limit the length of the post.
if ($parameters['length'] > 0 && $smcFunc['strlen']($row['body']) > $parameters['length'])
{
$row['body'] = $smcFunc['substr']($row['body'], 0, $parameters['length']);

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

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

$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);

// 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['topics'][$row['id_topic']] = array(
'id' => $row['id_topic'],
'board' => array(
'id' => $row['id_board'],
'name' => $row['board_name'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>',
),
'category' => array(
'id' => $row['id_cat'],
'name' => $row['cat_name'],
'href' => $scripturl . '#c' . $row['id_cat'],
'link' => '<a href="' . $scripturl . '#c' . $row['id_cat'] . '">' . $row['cat_name'] . '</a>',
),
'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['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'body' => $row['body'],
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['num_replies'] . ' ' . ($row['num_replies'] == 1 ? $txt['ssi_comment'] : $txt['ssi_comments']) . '</a>',
'replies' => $row['num_replies'],
'comment_href' => !empty($row['locked']) ? '' : $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';num_replies=' . $row['num_replies'],
'comment_link' => !empty($row['locked']) ? '' : '<a href="' . $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';num_replies=' . $row['num_replies'] . '">' . $txt['ssi_write_comment'] . '</a>',
'new_comment' => !empty($row['locked']) ? '' : '<a href="' . $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . '">' . $txt['ssi_write_comment'] . '</a>',
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'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['poster_name'] . '</a>' : $row['poster_name']
),
'locked' => !empty($row['locked']),
'is_last' => false,
);
$posters[$row['id_member']][] = $row['id_topic'];
$messages[] = $row['id_msg'];
$last = $row['id_topic'];
}

$smcFunc['db_free_result']($request);

// Get all the attachments, but only if we actually want them
if ($parameters['attachments'] != 'none' && !empty($modSettings['attachmentEnable']) && count(array_intersect($parameters['board'], boardsAllowedTo('view_attachments'))) > 0)
{
$request = $smcFunc['db_query']('', '
SELECT
a.id_attach, a.id_folder, a.id_msg, a.filename, IFNULL(a.size, 0) AS filesize, a.downloads, a.approved,
a.width, a.height, IFNULL(thumb.id_attach, 0) AS id_thumb, thumb.width AS thumb_width, thumb.height AS thumb_height, m.id_topic
FROM {db_prefix}attachments AS a
LEFT JOIN {db_prefix}attachments AS thumb ON (thumb.id_attach = a.id_thumb)
INNER JOIN {db_prefix}messages AS m ON (a.id_msg = m.id_msg)
WHERE a.id_msg IN ({array_int:message_list})
AND a.attachment_type = {int:attachment_type}' . (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : '
AND a.approved = {int:is_approved}'),
array(
'message_list' => $messages,
'attachment_type' => 0,
'is_approved' => 1,
)
);
$temp = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$temp[$row['id_attach']] = $row;
if (!isset($attachments[$row['id_msg']]))
$attachments[$row['id_msg']] = array();
}
$smcFunc['db_free_result']($request);

// This is better than sorting it with the query...
ksort($temp);

foreach ($temp as $attach_single)
{
$attachment = array(
'href' => $scripturl . '?action=dlattach;topic=' . $attach_single['id_topic'] . '.0;attach=' . $attach_single['id_attach'],
'filename' => htmlspecialchars($attach_single['filename']),
'filesize' => round($attach_single['filesize'] / 1024, 2) . ' ' . $txt['kilobyte'],
'width' => $attach_single['width'],
'height' => $attach_single['height'],
'imgsize' => $attach_single['width'] > 0 ? $attach_single['width'] . 'x' . $attach_single['height'] : '',
'downloads' => $txt['attach_viewed'] . ' ' . $attach_single['downloads'] . ' ' . $txt['attach_times'],
);
$attachment['thumbnail'] = $attach_single['id_thumb'] == 0 ? false : array(
'href' => $scripturl . '?action=dlattach;topic=' . $attach_single['id_topic'] . '.0;attach=' . $attach_single['id_thumb'] . ';image',
'width' => $attach_single['thumb_width'],
'height' => $attach_single['thumb_height'],
);
$return['topics'][$attach_single['id_topic']]['attachments'][] = $attachment;
}
}

// Get all the avatars, but only if we actually want them, then attach to the posts!
if ($parameters['avatar'] != 'none')
{
if ($modSettings['avatar_action_too_large'] == 'option_html_resize' || $modSettings['avatar_action_too_large'] == 'option_js_resize')
{
$avatar_width = !empty($modSettings['avatar_max_width_external']) ? ' width="' . $modSettings['avatar_max_width_external'] . '"' : '';
$avatar_height = !empty($modSettings['avatar_max_height_external']) ? ' height="' . $modSettings['avatar_max_height_external'] . '"' : '';
}
else
{
$avatar_width = '';
$avatar_height = '';
}

$poster_ids = loadMemberData(array_keys($posters));
foreach ($poster_ids as $member)
{
$topic = $posters[$member]; // to get back to $return
$profile = $user_profile[$member];
$avatar = array(
'image' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? '<img src="' . (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($profile['avatar'], 'http://') ? '<img src="' . $profile['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($profile['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) : '') : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']),
);

if ($avatar['href'] > '')
foreach ($topic as $tid)
$return['topics'][$tid]['poster']['avatar'] = $avatar;

}
}

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

$return['topics'][$last]['is_last'] = true;

$return['feed'] = array();

if (in_array('rss', $parameters['feed']))
$return['feed']['RSS'] = array(
'href' => $scripturl . '?action=.xml;sa=news;type=rss;boards=' . implode(',', $parameters['board']),
'link' => '<a href="' . $scripturl . '?action=.xml;sa=news;type=rss;boards=' . implode(',', $parameters['board']) . '">RSS</a>',
);

if (in_array('rdf', $parameters['feed']))
$return['feed']['RDF'] = array(
'href' => $scripturl . '?action=.xml;sa=news;type=rdf;boards=' . implode(',', $parameters['board']),
'link' => '<a href="' . $scripturl . '?action=.xml;sa=news;type=rdf;boards=' . implode(',', $parameters['board']) . '">RDF</a>',
);

if (in_array('rdf', $parameters['feed']))
$return['feed']['Atom'] = array(
'href' => $scripturl . '?action=.xml;sa=news;type=atom;boards=' . implode(',', $parameters['board']),
'link' => '<a href="' . $scripturl . '?action=.xml;sa=news;type=atom;boards=' . implode(',', $parameters['board']) . '">Atom</a>',
);

if ($parameters['output_type'] != 'echo')
return $return;

foreach ($return['topics'] as $news)
{
if ($parameters['avatar'] != 'none' && isset($news['poster']['avatar']))
$news['body'] = '<img class="ssi_avatar" src="' . $news['poster']['avatar']['href'] . '" style="margin:0 1em 1em 1em; float: ' . $parameters['avatar'] . '" />' . $news['body'];

echo '
<div>
', ($parameters['category_disp'] ? '[' . $news['category']['link'] . ']' : ''), ($parameters['board_disp'] ? ' [' . $news['board']['link'] . ']' : ''), ' <a href="', $news['href'], '">', $news['icon'], '</a> <strong>', $news['subject'], '</strong>
<div class="smaller">', $news['time'], ' ', $txt['by'], ' ', $news['poster']['link'], '</div>

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

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

if (!empty($news['attachments']))
{
$count = count($news['attachments']);
if ($count > 0) {
switch($parameters['attachments'])
{
case 'linkonly':
echo ' <ul>';
foreach ($news['attachments'] as $attach)
echo '
<li><a target="_blank" href="', $attach['href'], '">', $attach['filename'], '</a> (', ($attach['imgsize'] != '' ? $attach['imgsize'] . ', ' : ''), $attach['filesize'], ')</li>';
echo '
</ul>';
break;
case 'thumbnail':
foreach ($news['attachments'] as $attach)
{
echo '
<div class="ssi_attach" style="margin-top:0.3em;">';
if ($attach['thumbnail'])
echo '
<img src="', $attach['thumbnail']['href'], '" width="', $attach['thumbnail']['width'], '" height="', $attach['thumbnail']['height'], '" />';
echo '
<div class="ssi_attach_filename"><a target="_blank" href="', $attach['href'], '">', $attach['filename'], '</a></div>
<div class="ssi_attach_filesize">', $attach['filesize'], ($attach['imgsize'] != '' ? ', ' . $attach['imgsize'] : ''), '</div>';
echo '
</div>';
}
break;
case 'inline':
foreach ($news['attachments'] as $attach)
{
echo '
<div class="ssi_attach" style="margin-top:0.3em;">';
if ($attach['width'] > 0)
echo '
<img src="', $attach['href'], '" width="', $attach['width'], '" height="', $attach['height'], '" />';
echo '
<div class="ssi_attach_filename"><a target="_blank" href="', $attach['href'], '">', $attach['filename'], '</a></div>
<div class="ssi_attach_filesize">', ($attach['imgsize'] != '' ? $attach['imgsize'] . ', ' : ''), $attach['filesize'], '</div>
</div>';
}
break;
}
}
}

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

// Now, what about feeds

if (count($return['feed']) > 0)
{
$feeds = array();
foreach ($return['feed'] as $feed)
$feeds[] = $feed['link'];
echo '
<hr style="margin: 2ex 0;" width="100%" />
<div class="smalltext">', implode(' | ', $feeds), '</div>';
}
}


Then under the function for ssi_boardnews I have this.



// 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 $smcFunc;

loadLanguage('Stats');

// Must be integers....
if ($limit === null)
$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 3;
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 = $smcFunc['db_query']('', '
SELECT id_board
FROM {db_prefix}boards
WHERE ' . ($board === null ? '' : 'id_board = {int:current_board}
AND ') . 'FIND_IN_SET(-1, member_groups)
LIMIT 1',
array(
'current_board' => $board,
)
);
if ($smcFunc['db_num_rows']($request) == 0)
{
if ($output_method == 'echo')
die($txt['ssi_no_guests']);
else
return array();
}
list ($board) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_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 = $smcFunc['db_query']('', '
SELECT id_first_msg
FROM {db_prefix}topics
WHERE id_board = {int:current_board}' . ($modSettings['postmod_active'] ? '
AND approved = {int:is_approved}' : '') . '
ORDER BY id_first_msg DESC
LIMIT ' . $start . ', ' . $limit,
array(
'current_board' => $board,
'is_approved' => 1,
)
);
$posts = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$posts[] = $row['id_first_msg'];
$smcFunc['db_free_result']($request);

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

// Find the posts.
$request = $smcFunc['db_query']('', '
SELECT
m.icon, m.subject, m.body, IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time,
t.num_replies, t.id_topic, m.id_member, m.smileys_enabled, m.id_msg, t.locked, t.id_last_msg
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
WHERE t.id_first_msg IN ({array_int:post_list})
ORDER BY t.id_first_msg DESC
LIMIT ' . count($posts),
array(
'post_list' => $posts,
)
);
$return = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
// If we want to limit the length of the post.
if (!empty($length) && $smcFunc['strlen']($row['body']) > $length)
{
$row['body'] = $smcFunc['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'] = $smcFunc['substr']($row['body'], 0, $cutoff);
$row['body'] .= '...';
}

$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);

// 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" alt="' . $row['icon'] . '" />',
'subject' => $row['subject'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'body' => $row['body'],
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['num_replies'] . ' ' . ($row['num_replies'] == 1 ? $txt['ssi_comment'] : $txt['ssi_comments']) . '</a>',
'replies' => $row['num_replies'],
'comment_href' => !empty($row['locked']) ? '' : $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';last_msg=' . $row['id_last_msg'],
'comment_link' => !empty($row['locked']) ? '' : '<a href="' . $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';last_msg=' . $row['id_last_msg'] . '">' . $txt['ssi_write_comment'] . '</a>',
'new_comment' => !empty($row['locked']) ? '' : '<a href="' . $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . '">' . $txt['ssi_write_comment'] . '</a>',
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'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['poster_name'] . '</a>' : $row['poster_name']
),
'locked' => !empty($row['locked']),
'is_last' => false
);
}


$parameters = array(
  'limit' => 15,
  'board' => array(1,2),
  'category' => array(12),
  'board_disp' => true,
  'category_disp' => true,
  'avatar' => 'left',
  'icon' => 'thumbup',
  'attachments' => 'inline'
 
 
);
ssi_multiBoardNews($parameters);




$smcFunc['db_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 '
    <table width="595" border="0" cellspacing="0" cellpadding="0">
      <tr>
    <td height="29"><div id="article-body-t"></div>
<div id="article-body-m">', $news['icon'], ' <a href="', $news['href'], '">', $news['subject'], '</a></div></td>
  </tr></table>
 

   
   
    <table width="595" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><div id="articles"><div id="article-body-c">
  <table width="595" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="595"><table width="595" border="0" cellspacing="0" cellpadding="9">
          <tr>
            <td width="149" height="290" valign="top">Posted: ', $news['time'] , '<br>
              <br>
              Posted by:', '<br>
              ', $news['poster']['link'], '</td>
            <td width="410">


<a href="', $topic['first_post']['href'], '"><img src="', $image['url'], '" width="', $image['width'], '" height="', $image['height'], '" alt="" /></a>
<br>
', $parameters['attachments'], '




</td>
          </tr>
        </table></td>
    </tr>
    <tr>
      <td height="32" bgcolor="#002035" align="right" style="padding-right: 10px;">', $news['link'], $news['locked'] ? '' : ' - ' . $news['comment_link'], '</td>
    </tr>
    <tr>
      <td height="5"></td>
    </tr>
  </table>
</div>
<div id="article-body-d"></div></td>
  </tr>
</table>

   
    </div>


';

if (!$news['is_last'])
echo '';
}
}



Example of page output:
http://goo.gl/M1id2 (short temporary url) - index.php page

Arantor

What I don't get is why you modified ssi_boardnews at all. The whole point of the install is that it adds a NEW function, one that is designed to REPLACE ssi_boardnews rather than merely extend it.

Seriously, just put the call to include SSI.php, then the call to ssi_multiBoardNews, and put the function BACK at the end of SSI.php where it's supposed to be, then tell me what happens.

ModelitMatt

So you mean for index page use:

<?php ssi_multiBoardNews(); ?>

Instead of

<?php ssi_boardNews(); ?>

?

I think I under estimated what the mod did.

Also where is
$parameters = array(
  'limit' => 15,
  'board' => array(1,2),
  'category' => array(12),
  'board_disp' => true,
  'category_disp' => true,
  'avatar' => 'left',
  'icon' => 'thumbup',
  'attachments' => 'inline'
 
 
);
ssi_multiBoardNews($parameters);


supposed to be?
After the requirement for the SSI page on the index page just below it, or within the SSI?

I apologize if I am still misunderstanding and appreciate you taking the time to help me with this.

Arantor

Quotesupposed to be?
After the requirement for the SSI page on the index page just below it, or within the SSI?

You load SSI.php on the page, then add that code after it, since it's a function that's part of SSI.php (well, it is when it's untouched)

ModelitMatt

<?php require("/*location to ssi* /SSI.php"); 

$parameters = array(
  
'limit' => 15,
  
'board' => array(1,2),
  
'category' => array(12),
  
'board_disp' => true,
  
'category_disp' => true,
  
'avatar' => 'left',
  
'icon' => 'thumbup',
  
'attachments' => 'inline' 
  
  
);
ssi_multiBoardNews($parameters);?>



I tried that as above but the code isn't pushing out the attachment, from what you see above did I miss anything or alter something to mess it up?

(I took out SSI's direct location as could be dangerous to show)

Arantor

So what HTML is being generated on that test page you have? (I'm assuming that now the function is present at the end of SSI.php as it came out of the mod's package)

ModelitMatt

Nothings being generated.

I tried making a new test page with the following code:

<?php require("/ **Link to SSI Hidden* /SSI.php"); 

$parameters = array(
  
'limit' => 15,
  
'board' => array(1,2),
  
'category' => array(12),
  
'board_disp' => true,
  
'category_disp' => true,
  
'avatar' => 'left',
  
'icon' => 'thumbup',
  
'attachments' => 'inline' 
  
  
);
ssi_multiBoardNews($parameters);?>



<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">SSI_MULTIBOARDNEWS -------------- BELOW
<br />
<br />
<br />
<?php ssi_multiBoardNews(); ?></td>
</tr>
    <td valign="top">SSI_BOARDNEWS-------------- BELOW
<br />
<br />
<br />
<?php ssi_boardNews(); ?>
</td>
  </tr>
</table>




http://www.modelitup.com/final_modelitup/new_test.php"

I did keep your mod just before "?>" and it hasn't been adjusted.

Arantor

There are two calls to ssi_multiBoardNews and the first one is displaying nothing. The second one is giving you nonsense because it's not being given any parameters, and the third call is to ssi_boardNews which isn't relevant anyway at this point.

So, let's look at the parameters of relevance...

Quote'limit' => 15,
  'board' => array(1,2),
  'category' => array(12),
  'board_disp' => true,
  'category_disp' => true,

Out of interest why are you specifying both board and category? If you want all the boards in a category, use the category. If you want just some boards, just use some boards and don't specify the category.

ModelitMatt

It was part of an example provided on the documentation on the mod page I didn't modify it.

In attempt to understand more I've removed the ssi_boardnews script from the test page as I see why its no longer relevant.

I have removed the one I believe you said wasn't going to provide anything because it was not given parameters.
ssi_multiBoardNews($parameters);

I have altered the board and removed the category field.
The page code is now

<?php require("/ **Link to SSI Hidden* /SSI.php"); 

$parameters = array(
  
'limit' => 15,
  
'board' => array(1.0),
  
'board_disp' => true,
  
'category_disp' => true,
  
'avatar' => 'left',
  
'icon' => 'thumbup',
  
'attachments' => 'inline' 
    
);
?>


<?php ssi_multiBoardNews(); ?>


It seems nothings being output though.

Does that suggest there is a problem on the ssi.php file or my array above?

Arantor

No, now it's going to still output rubbish since the one that was outputting garbage like null attachments is the one WITHOUT parameters being passed to it.

<?php require("/ **Link to SSI Hidden* /SSI.php"); 

$parameters = array(
  
'limit' => 15,
  
'board' => array(1.0),
  
'board_disp' => true,
  
'category_disp' => true,
  
'avatar' => 'left',
  
'icon' => 'thumbup',
  
'attachments' => 'inline' 
    
);
ssi_multiBoardNews($parameters); ?>


You have to set the parameters then pass them to ssi_multiBoardNews. Now the values are more sensible, odds are something will result that's useful.

ModelitMatt

I tried adjusting it to that but it's not linking up with the attached image, it's still showing blank.

Is it configured properly for this example post:
http://modelitup.com/articles/index.php?topic=5.0

It's within board 1.0

Arantor

So, what's the link to it? Any of the above links?

ModelitMatt

Links:

Example Post
http://modelitup.com/articles/index.php?topic=5.0

Test Page
http://www.modelitup.com/final_modelitup/new_test.php

Current Code


<?php require("/ *removed* /SSI.php"); 

  
$parameters = array(
  
'limit' => 15,
  
'board' => array(1.0),
  
'board_disp' => true,
  
'category_disp' => true,
  
'avatar' => 'left',
  
'icon' => 'thumbup',
  
'attachments' => 'inline' 
    
);
ssi_multiBoardNews($parameters); ?>




SSI code is as was in past posts no adjustments to it.

Arantor

That just gives me an HTTP 500 error which suggests something else is wrong.

Note that you shouldn't use 1.0 as the board number since it's not 1.0, just 1

ModelitMatt

Yea it gave me the same thing, I tried 1 as well which is what I've switched it to now but still same result.

Arantor



Arantor

I know why you get nothing.

None of the topics have a first post whose icon is the thumbs up icon. So none of them match that criteria - and nothing is displayed as a result.

ModelitMatt

omg! that was it! :D

Thanks tons !

I guess I just modify the body in the ssi now to make it custom?

Wow, even shows the avatar, so much better :D!!!

Arantor

You can, or you can use the output method parameter to just get an array of information back and then output it with whatever code you like.

ModelitMatt

Are you able to provide an example of an output method.

I would need to output the

  • Icon
  • Title
  • Attachment
  • Post Date
  • Posted By
  • Comment
  • Write Comment

Arantor

Given that it's 2am, I probably should be in bed. But really, you could just try it... or read the mod's actual support thread where I'm sure at least one person already did that.

Or if you feel so inclined just modify the mod's code. It will naturally break uninstalling it though...

ModelitMatt

No worries, I'm thankful you assisted me to this point you were tons of help :)
Have a great sleep and I will keep looking into how to work with the mod rather than modify the code.

Thanks for the advice and I look forward to using this :D
Thanks for contributing to SMF and congratulations on 40,000+ posts, I'm sure you've helped tons!

Thanks again :)

Advertisement: