News:

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

Main Menu

SSI Multiple Board News (ssi_multiBoardNews)

Started by vbgamer45, December 25, 2009, 01:57:08 AM

Previous topic - Next topic

Deadfire

Quote from: Arantor on March 13, 2013, 08:31:57 PM
That's the reason I want to see for myself - but I'm not going to do the PM tag dance (nothing personal, I just don't like doing anything in private) - because in about 85% of the cases where "it's set up like I described..." it isn't.

I can understand that mate, but as I said it's pre-dev and hidden away for that purpose. Is there another way other then myself making up a public mock up somewhere?

Deadfire

I think I have my issue with the code for display. I have the following:


$parameters = array(
'limit' => 5,
'board' => array(1,2,3,4,5),
'output_type' => 'array',
'attachments'=> ''thumbnail',
);
$return = ssi_multiBoardNews($parameters);
foreach ($return['topics'] as $news)
{
echo'
<article>
<h2>', $news['subject'], '</h2>
<p class="pubdate">written by ', $news['poster']['link'], ', <time datetime="2013-03-01T12:00:00-05:00">', $news['time'], '</time></p>
<p class="pubdate">posted in ', $news['board']['link'], '</p>
<hr />
<p>', $news['body'], '</p>';
if (isset($news['attachments']))               
                     echo '
            <p><img src="', $news['attachments']['href'], '"/></p>';         
echo' <hr />
<p class="read">', $news['link'], ' | ', $news['new_comment'], '</p>
</article>
<hr class="article-divider" />';

if (!$news['is_last'])
echo '
<hr>
<br />';
}


thinking that my syntax here is wrong
    echo ' <p><img src="', $news['attachments']['href'], '"/></p>'; 

As it sits I get a blank img src

Suki

You always need to check for any var you would want to use before actually using it,  you don't know if the topic have any attachments or if the attachments are images.

Do a var_dump()  on $news['attachments'] to see what exactly does it contains:  var_dump($news['attachments']);
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Deadfire

Quote from: Suki on March 26, 2013, 06:33:36 PM
You always need to check for any var you would want to use before actually using it,  you don't know if the topic have any attachments or if the attachments are images.

Do a var_dump()  on $news['attachments'] to see what exactly does it contains:  var_dump($news['attachments']);

Aye, it is returning as NULL, which I guess is a issue with the function then?

Suki

Well, does the topics you want to fetch actually has any attachments?
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Deadfire

Quote from: Suki on April 03, 2013, 09:10:36 PM
Well, does the topics you want to fetch actually has any attachments?

Yes it does

Deadfire

Quote from: Deadfire on April 03, 2013, 09:40:02 PM
Quote from: Suki on April 03, 2013, 09:10:36 PM
Well, does the topics you want to fetch actually has any attachments?

Yes it does


I must make a edit here I may have missed it but var dumping did reveal the arrays


array(1) { [0]=> array(8) { ["href"]=> string(86) "http://*****/forum/index.php?action=dlattach;topic=12.0;attach=4" ["filename"]=> string(30) "*****.jpg" ["filesize"]=> string(9) "796.64 kB" ["width"]=> string(4) "2550" ["height"]=> string(4) "3299" ["imgsize"]=> string(9) "2550x3299" ["downloads"]=> string(14) "viewed 0 times" ["thumbnail"]=> array(3) { ["href"]=> string(92) "http://*****/labs/forum/index.php?action=dlattach;topic=12.0;attach=5;image" ["width"]=> string(3) "386" ["height"]=> string(3) "500" } } }


*****s of course added by myself.

Deadfire

doing a bump on this just wondering if there would be a answer

Deadfire

This is fixed the issue was because there can be more then 1 attachment you need to make sure you need to make sure to set that.

so

<img src="', $news['attachments'][0]['thumbnail']['href'], '"/> will give you your result :)

Suki

Well, I assumed  you already knew that the attachments var was actually an array containing all possible attachments for said post.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Deadfire

Well after the issue with attachments thats more my fault then anything I do have a question.

Is it possibly to add some sort of page break function, or hidden text function to the post that's displayed?

The issue I have is working with a Character limit of 500, the articles that are posted up are much longer and contain a lot of bbcode for formatting. The limit has a habit of cutting off during bbcode leading to things like "[font=arial..." and looking for a way to have the author to force a break.

Suki

Not easy, at least not without building a robust func, I got a func for truncating a string but it doesn't handle HTML or BBC so most of the times you end up with broken code.

There are several attempts floating around:
http://stackoverflow.com/questions/1193500/php-truncate-html-ignoring-tags
http://alanwhipple.com/2011/05/25/php-truncate-string-preserving-html-tags-words/
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Deadfire

#212
I'm having a bit of a issue trying to show a single board, The code works just fine for more then 1 though....

I'm getting 'Invalid argument supplied for foreach()'

This is my code:

<?php
$parameters = array(
'limit' => 5,
'board' => 2,
'output_type' => 'array',
'length' => 500,
'attachments'=> 'thumbnail',
);
$return ssi_multiBoardNews($parameters);
foreach ($return['topics'] as $news)
{

echo'
<article>
<h2>'
$news['subject'], '</h2>
<p class="pubdate">written by '
$news['poster']['link'], ', <time datetime="2013-03-01T12:00:00-05:00">'$news['time'], '</time></p>
<p class="pubdate">posted in '
$news['board']['link'], '</p>
<hr />
<p>'
$news['body'], '</p>';
if (isset($news['attachments']))
                     echo 
'
            <br><p><a href="'
$news['attachments'][0]['href'], '"><img src="'$news['attachments'][0]['thumbnail']['href'], '"/></a></p>'
echo' <hr />
<p class="read">'
$news['link'], ' | '$news['new_comment'], '</p>
</article>
<hr class="article-divider" />'
;

if (!$news['is_last'])
echo '
<hr>
<br />'
;
}
echo'<div class="clear-fix"></div>';

echo '</div>';

echo '</div>';
?>



var_dump ($parameters); gives;

array(5) { ["limit"]=> int(5) ["board"]=> int(2) ["output_type"]=> string(5) "array" ["length"]=> int(500) ["attachments"]=> string(9) "thumbnail" }

Arantor

What foreach()?

Also, how modified is your version of this?

Deadfire

Quote from: Arantor on May 11, 2013, 10:59:15 PM
What foreach()?

$return = ssi_multiBoardNews($parameters);
foreach ($return['topics'] as $news)


Quote from: Arantor on May 11, 2013, 10:59:15 PMAlso, how modified is your version of this?

The function should have no changes other then the fix for boardsAllowedTo() having strange properties for admins. link here

but for a more clear reading here it is:

// 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 . '?board=' . $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']) && ($context['user']['is_admin'] || 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>';
}
}



Arantor

If the foreach is invalid, $return['topics'] isn't an array, which suggests there's something funny going on.

Deadfire

Quote from: Arantor on May 11, 2013, 11:40:56 PM
If the foreach is invalid, $return['topics'] isn't an array, which suggests there's something funny going on.

I agree, thats why I found it odd that it works for multiple boards, but not for a single one.

'board' => array(1,2,3,4,5),
works, but

'board' => array(2), or 'board' => 2,
does not

Arantor

So, board 2 has some content in it, right?

Deadfire

Quote from: Arantor on May 11, 2013, 11:46:39 PM
So, board 2 has some content in it, right?

Indeed it does.(83 topics in total)

Arantor

Then I see no reason for it to be failing. It's not like I left the limiter in it that was in the original ssi_boardNews that only took the last % of topics for a board.

But there's something definitely awry somewhere, but it's late and I can't see anything obviously wrong. If I remember and have time I'll look into it, but I wouldn't hold your breath. Revisiting my old mods is not my normal idea of fun.

Advertisement: