I cannot get this
ssi_recentTopics('8', array('3','56') , 'array') to specifically use a board for nothing!
I have tried everything, and it continually lists recent topics from all boards.
Any time you put quotes around a number PHP treats it like a string. You should try this instead.
ssi_recentTopics(8, array(3,56) , 'array')
ok, so now I have this
$what=ssi_recentTopics(8, array(4) , 'array');
And it still doesn't work properly. I know that just a 4 is not a number array, but I don't know how else to add it. I just want board 4 displayed.
ssi_recentTopics does not work that. It only allows you to "exclude" the boards you don't want topics from. There are some codes in this board that do what you want if you search through them though.
So the array number is boards I want to exclude, so in the example above I am excluding board 4?
Insanemustang,
Not sure what you're trying to do exactly, but if you want to "include" boards instead of excluding them you might want to take a look at this topic starting with this message ---> http://www.tinyportal.net/index.php/topic,25497.msg204282.html#msg204282
If that does what you want to do, let Ichbin know here.
ZarPrime
in the original post it says
Quote- add board ID number like to the function if youw ant to narrow down the boards recent topics are taken from. change it to ssi_recentTopics('8', array('3','56') , 'array') where the numbers 3 and 56 are examples of board ID's.
i assume block actually meant, where recent topics are NOT taken from?
Zar, I guess that code may do what I need since it says, "include boards"?
I guess that could sound a little confusing. Maybe instead of "narrow down" it should say "exclude".
Anyway, try that other topic and see if that might do what you're looking for.
ZP
I tried it and it doesn't help me much. I don't understand why I just can't include X boards into the script I am running in this block?
global $scripturl;
$what=ssi_recentTopics(8, array(1,5) , 'array');
foreach ($what as $topic)
{
echo '<br><span class="smalltext">', $topic['link'], '</span>';
// Is this topic new? (assuming they are logged in!)
if (!$topic['new'] && $context['user']['is_logged'])
echo '
<a href="', $scripturl, '?topic=', $topic['topic'], '.msg', $topic['new_from'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
}
I want to include board X, instead of excluding Y & Z...
Because smf didn't write their ssi_recentTopics to work like that. The link that Zarprime posted for you does exactly what you're asking for though.
insanemustang,
I may still be a little confused as to what you want to do, but if that other one didn't do it, you might want to take a look at this code that JPDeni posted a couple of years ago. I don't think it gives you everything that is in a normal recent posts block using the SSI function, but it will give you the most recent topics from a particular board or boards that you specify near the top of the code. The link is here ---> http://www.tinyportal.net/index.php/topic,1234.msg81842.html#msg81842
If that doesn't do it, you might want to post a new topic in Block Code requests and let somebody take a stab at what you're looking for.
ZarPrime
I also want very to understand this ???
where folder I put this?
ssi_recentTopics('8', array('3','56') , 'array'):
pedrox,
you don't have to put it anywhere.
ssi_recentTopics is a function that is already built into SMF. This block only makes use of it. The 8 specifies how many topics to show, and the other 2 numbers specify boards to exclude.
I know this is a long topic but if you want to know what the block code is all about, you would be better off to start back on page 1 of this topic and read what it's all about starting here ---> http://www.tinyportal.net/index.php/topic,596.msg4654.html#msg4654
ZarPrime
Ok, I used the code in that thread. And I customized the look of it, but the "new" icon's link points straight to this "......index.php?topic=Array.from#new" and it goes to the home page, not to that thread's newest post.
Seo installed ?
nope
Then tell us your setup, what you have done, how you done it, and what you have tried so we dont have to ask for every thing ;) :D
insanemustang,
I have split your posts into this new topic because what you are trying to do is include boards instead of exclude boards. This will keep people from getting confused about the original topic.
Please post your info in this topic as G6 suggested instead of the original one so that we can help you.
ZarPrime
Thanks.
I used the include code, and was able to get it working, kind of. Let me show you my code first.
global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
global $user_info, $modSettings, $func;
$num_recent = 10;
$include_boards = array(5);
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$include_boards = empty($include_boards) ? array() : $include_boards;
$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 all the posts in distinct topics. Newer ones will have higher IDs.
$request = db_query("
SELECT
m.posterTime, ms.subject, m.ID_TOPIC, t.numReplies, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . "
AND t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($include_boards) ? '' : "
AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
" . ((!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) ? "
AND b.ID_BOARD != '$modSettings[recycle_board]'" : '') . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAST_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '
')));
if ($func['strlen']($row['body']) > 128)
$row['body'] = $func['substr']($row['body'], 0, 128) . '...';
// Censor the subject.
censorText($row['subject']);
censorText($row['body']);
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';
// Build the array.
$result[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => array(
'id' => $row['ID_TOPIC'],
'views' => $row['numViews'],
'replies' => $row['numReplies'],
),
'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']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
);
}
mysql_free_result($request);
// Print out the results
echo '<center><img src="http://www.bamanation.net/images/footballnews.png"></center>';
echo '<span class="smallertext">';
foreach($result as $my){
echo "$bullet";
echo '<span class="smalltext">'.$my['link'],' ';
echo '(', '<span class="smalltext">'.$my['topic']['replies'],') ';
// is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo '
<a href="', $scripturl, '?topic=', $my['topic'], '.msg', $my['newtime'], '#new">
<img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo '</span>';
echo '<span class="largetext">','<br>';
}
And attached is a screenshot of how it looks. Problem is that I have this code running in 2 blocks, both identical code other than the number of the board included, and the image code being different. But the code on the right is only displaying 4 threads, not the full 10 as I have inside of the code.
Well, I'm not a php Guru but it may have something to do with running 2 instances of the same code. Perhaps JPDeni, the php Guru, will step in here for a moment and take a look at this. She may know of some reason this is happening right off the top of her pretty head. ;)
ZarPrime
I could understand if it didn't display any, but for it to display just 4... it's suspicious to say the least. And the new.gif icon still doesn't take me to the latest post in the thread like it's supposed to :(
BTW, I have SMF 1.1.7 and TP 1.0.5 Beta 1
Since it's working right in one, the logic must be right. There's something else going on.
Try changing
WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . "
AND t.ID_LAST_MSG = m.ID_MSG
to
WHERE t.ID_LAST_MSG = m.ID_MSG
Basically, you're just taking out some code. I'm wondering if there just aren't enough posts that are recent enough to fill out the list. We'll see from this whether that's true or not. I think. :)
I'd have to look at your site to get an idea of why the New .gif isn't working.
Quote from: JPDeni on January 09, 2009, 09:41:47 PM
Since it's working right in one, the logic must be right. There's something else going on.
Try changing
WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . "
AND t.ID_LAST_MSG = m.ID_MSG
to
WHERE t.ID_LAST_MSG = m.ID_MSG
Basically, you're just taking out some code. I'm wondering if there just aren't enough posts that are recent enough to fill out the list. We'll see from this whether that's true or not. I think. :)
I'd have to look at your site to get an idea of why the New .gif isn't working.
BINGO! Thank you so much, this has disturbed me for months.
The actual gif is working, the link for the graphic doesn't work. Site is http://www.bamanation.net
any idea about the new.gif ?
Quote from: insanemustang on January 13, 2009, 03:30:00 PM
any idea about the new.gif ?
anyone? when i click the new.gif it takes me to a page with nothing on it
InsaneM,
You appear to have 3 different blocks on your site for 3 different boards. Are you using the same code in all 3?
Please post the most current code you are using here inside BBC code tags, and somebody will be able to take a look at the problem. Is the only problem that clicking the new.gif doesn't take you to the newest messages or are there other issues as well?
Also, whoever looks at this for you will probably need for you to setup a temp Admin account for them so you might as well go ahead and set it up and be prepared to PM them the details once they ask for them.
ZarPrime
Ok,
The only problem I am experiencing is that the new.gif doesn't take you to the newest post in that thread, instead it takes you to this weird url
"...index.php?topic=Array.from#new"
Here is a the code from one of my blocks
global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
global $user_info, $modSettings, $func;
$num_recent = 6;
$include_boards = array(26,62,63);
$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';
$include_boards = empty($include_boards) ? array() : $include_boards;
$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 all the posts in distinct topics. Newer ones will have higher IDs.
$request = db_query("
SELECT
m.posterTime, ms.subject, m.ID_TOPIC, t.numReplies, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
WHERE t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($include_boards) ? '' : "
AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
" . ((!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) ? "
AND b.ID_BOARD != '$modSettings[recycle_board]'" : '') . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAST_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '
')));
if ($func['strlen']($row['body']) > 128)
$row['body'] = $func['substr']($row['body'], 0, 128) . '...';
// Censor the subject.
censorText($row['subject']);
censorText($row['body']);
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';
// Build the array.
$result[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => array(
'id' => $row['ID_TOPIC'],
'views' => $row['numViews'],
'replies' => $row['numReplies'],
),
'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']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
);
}
mysql_free_result($request);
// Print out the results
echo '<blockquote><img src="http://www.bamanation.net/images/websitenews.png"></blockquote>';
echo '<span class="smalltext">';
foreach($result as $my){
echo "$bullet";
echo '<span class="normaltext">'.$my['link'],' ';
echo '(', '<span class="smalltext">'.$my['topic']['replies'],') ';
// 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['newtime'], '#new">
<img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo '</span>';
echo '<span class="largetext">','<br>';
}
Thank for any and all help.
This is not right:
echo '<a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], '#new">
The reason you're getting Array is that the $my['topic'] is an array.
'topic' => array(
'id' => $row['ID_TOPIC'],
'views' => $row['numViews'],
'replies' => $row['numReplies'],
),
The from text is something that you've put in there and there is no ['newtime'] defined, so you get nothing from that. (You also likely are getting an error in your error log.)
I'm not sure what it is that you're wanting to do. If you want to send people to the most recent post in a topic, use
echo '<a href="' . $my['href'] . '">
Thanks for the help, I'm going to try it now.
Replaced
echo '<a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], '#new">
with
echo '<a href="' . $my['href'] . '">
and got
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home3/insanem2/public_html/bamanation/Sources/Load.php(1754) : eval()'d code(48) : eval()'d code on line 94
try adding an apostrophe & semicolon at the end ';
echo '<a href="' . $my['href'] . '">';
You might not need the apostrophe '
There was not a semi-colon in the original, which is why I didn't put it into the replacement code.
You'll need to post the whole section in order to see where the problem is.
:P I'll be quiet..
Quote from: JPDeni on March 15, 2009, 04:50:30 PM
You'll need to post the whole section in order to see where the problem is.
I'm assuming you mean the part that's displayed? Here is the code.
// Print out the results
echo '<blockquote><img src="http://www.bamanation.net/images/websitenews.png"></blockquote>';
echo '<span class="smalltext">';
foreach($result as $my){
echo "$bullet";
echo '<span class="normaltext">'.$my['link'],' ';
echo '(', '<span class="smalltext">'.$my['topic']['replies'],') ';
// 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['newtime'], '#new">
<img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo '</span>';
echo '<span class="largetext">','<br>';
}Thanks for all the help. I have no doubt that this will be solved soon.
// Print out the results
echo '<blockquote><img src="http://www.bamanation.net/images/websitenews.png"></blockquote>';
echo '<span class="smalltext">';
foreach($result as $my){
echo "$bullet";
echo '<span class="normaltext">'.$my['link'],' ';
echo '(', '<span class="smalltext">'.$my['topic']['replies'],') ';
// is this topic new? (assume they are logged in)
if (!$my['new'] && $context['user']['is_logged'])
echo '<a href="' . $my['href'] . '">
<img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
echo '</span>';
echo '<span class="largetext">','<br>';
}
I got no syntax errors in that code.
i know, but the new image doesn't take you anywhere...
I thought the problem we were dealing with at the moment was the syntax error. That's the last error you posted.
What is the link that it gives?
ETA: I just realized what's going on.
I gave you a line of code. You pasted that line into your code incorrectly and got a syntax error.
You pasted a bit of the original code (withouth the revised line) into a post. I copied that code *and made the change of the one line that I had made before* into your bit of code. I posted *the altered code* into a post.
You thought that I just checked your original code, and, without trying the code that I posted, said it didn't take you anywhere. I was thinking that you meant that the new code I gave you didn't take you anywhere. Then I thought about it a bit and realized that you didn't try the new code at all.
Paste the most recent code I posted into your block and see what happens. If you have a syntax error, it will be in some other place in your code. If you still have problems with the link, post what the link actually says so that I will know where to look for the problem.
Strange... I posted exactly what you gave me back into a block so I could give you the syntax error, and the entire code... and it worked perfectly.
I don't know what happened, but I am extremely sorry I wasted your time for a day on this.
Thank you so much for your help.
That's okay. It happens. :)
I'm glad it worked for you. All's well that ends well!