News:

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

Main Menu

ssi_recentTopics customization

Started by MarkoKg, November 01, 2017, 02:41:03 PM

Previous topic - Next topic

MarkoKg

Hey there,

I'd like to be able to pass the variable into parameter for the ssi_recentTopics, like current syntax is:
<?php ssi_recentTopics($num_recent 8$exclude_boards null$include_boards null$output_method 'echo'); ?>
I'd like to have $include_boards = $myvariable
Is that possible?

For example, for each board ID i'd like to be able to add it through BoardIndex.template, like so:

$number= $board['id'];
ssi_recentTopics($num_recent = 3, $exclude_boards = null, $include_boards = $number, $output_method = 'echo');

So i can have last three topics showed in "last post" column instead of current one last post.

Arantor

You mean...

ssi_recentTopics(3, null, $board['id'], 'echo');

MarkoKg

Just tried that..

Complete code:

// Show some basic information about the number of posts, etc.
echo '</td>
<td class="lastpost">';
ssi_recentTopics(3, null, $board['id'], 'echo');
echo'
</td>
</tr>';


That output just white space in the column, nothing is shown even though there's topics in each board.


Do note that when i try to print $board['id'] it's giving me the IDs for each board, so that variable is correct. I'm just not sure why it won't work when I use it as a parameter for that ssi function.

Arantor

Well, does $board['id'] contain something? If you're outside of SMF, it probably doesn't contain the currently loaded board...

MarkoKg

It does contain ID of boards. When I print $board['id'] it's showing IDs of each board in that column where "lastpost" usually is, so that is working.

Arantor

When do you print this? Where does this information come from exactly?

Where is this SSI code you're trying to use? SSI code inside SMF usually ends badly...

MarkoKg

Oh, that's what's the problem in that case. I'm using this in BoardIndex.template.php just under the
// Show some basic information about the number of posts, etc.

I tried to print $board['id'] before calling ssi_recentTopics.
Do note that I haven't requred SSI.php itself, as I assume that I don't need to when I'm inside SMF actually.
What would be the better way to perform this?

Arantor

Uh...

SSI functions aren't loaded inside SMF - ever. SSI will actually try to abort if it detects being run inside SMF because you're *really* not supposed to do that. I'm mildly amazed it didn't give you a more serious error, actually.

Do none of the portals have a block designed for this (and do it faster and more efficiently than trying to mangle SSI into SMF)?

MarkoKg

Sorry, I really wasn't aware of that, and as I haven't found another way to do that, I assume ssi would do the trick even though it's not the *best* solution though.
Here's attached example of another SMF forum that I saw with the same feature that I'd like to implement - having 3 last topics listed on boardIndex for each board. I don't think that portal mods can achieve that though.

Arantor

Wait... running a query for every single board? Ouch.

MarkoKg

lol, that wasn't enthusiastic :D

Like I said, not really sure what would be the best approach, that's something I wanted to have, with ssi or whatever method is right. And as that forum I found has that - I assume it can be done somehow.

Arantor

That's because it's a really bad thing to do from a performance perspective - there is literally no way to do it other than a query per board, and that means if you have a dozen boards on show, you have a dozen extra queries.

...and for information that in my experience users don't really care about. On fast moving boards, it doesn't really show you anything, on slow moving boards it actually seems to discourage participation.

MarkoKg

I'm building small(er) community for a limited number of members, which will have only 4-5 boards, would that be a huge impact to the performance?

Arantor

Will search engines be involved?

Also... if it's only a limited number of members, it probably ends up not being quite so busy, so the topic list ends up not moving so it seems to discourage people.

If it's only in the board index, it's not quite so bad, but it's not great.

MarkoKg

Forum itself will be closed for public, so no search engines. Portal will be public though. It's related to university project(s), and idea behind 3 last topic per board is for students to be able to see when new course is starting (each semester for each subject) before entering the board itself.

So I don't worry about discouraging members, as the goal behind this isn't quantity, but quality.

Advertisement: