SimplePortal
Customization => Blocks and Modifications => Block Requests => Topic started by: goten22 on August 26, 2015, 06:48:57 PM
-
I'm looking for some way to expand/merge those two scripts:
http://simpleportal.net/index.php?topic=1621.0 - recent topics with exclude boards
http://simpleportal.net/index.php?topic=2132.0 - recent topics with include
But i want to introduce some extra things for topics from secific boards. For example:
(http://i.imgur.com/cOWmbVL.jpg)
I want to add specific images for specific boards. I will appreciate any help, thanks
-
Figured it out.
<?php
$new_topics=ssi_recentTopics(10, null, null, 'array');
$board_ukonczone=3;
$board_wip=1;
foreach ($new_topics as $topic) {
if($topic['board']['id']==$board_ukonczone){
echo'
<div class="topic_list"><a href="" class="d_block">3D</a> ' . $topic['link'] . ' — ' . $topic['poster']['link'] . ' | Comments: ' . $topic['replies'] . ' </div>';
} elseif($topic['board']['id']==$board_wip){
echo'
<div class="topic_list"><a href="" class="d_block">WIP</a> ' . $topic['link'] . ' — ' . $topic['poster']['link'] . ' | Comments: ' . $topic['replies'] . ' </div>';
} else{
echo'
<div class="topic_list"><img src="/Themes/flatline/images/post/xx.gif" alt="' . $topic['board']['name'] . '"/>' . $topic['link'] . ' — ' . $topic['poster']['link'] . ' | Comments: ' . $topic['replies'] . ' </div>';
}
}
-
Glad you figured it out! The only thing that comes to my mind while looking at it would be using $imagesdir instead of the raw image path, but other than that thanks for posting the solution! I'll go ahead and mark the topic as solved ;)
EDIT: looking at it again... Why using board id variables? Could have used numbers directly if I'm not mistaken...
-
Sure, but I'm testing whole forum so even id boards are not final and I want to modify them quickly and easily. ;)
-
Indeed, using direct IDs *should* be actually faster :P I could be wrong because I am sleepy and didn't even dig into it properly.
-
Here is a couple of ways I would have done it.
<?php
$zone_topics = ssi_recentTopics(10, null, array(3), 'array');
$wip_topics = ssi_recentTopics(10, null, array(1), 'array');
$remaining_topics = ssi_recentTopics(10, array(1, 3), null, 'array');
foreach ($zone_topics as $topic)
echo '<div class="topic_list"><a href="" class="d_block">3D</a> ' . $topic['link'] . ' — ' . $topic['poster']['link'] . ' | Comments: ' . $topic['replies'] . ' </div>';
foreach ($wip_topics as $topic)
echo '<div class="topic_list"><a href="" class="d_block">WIP</a> ' . $topic['link'] . ' — ' . $topic['poster']['link'] . ' | Comments: ' . $topic['replies'] . ' </div>';
foreach ($remaining_topics as $topic)
echo '<div class="topic_list"><img src="/Themes/flatline/images/post/xx.gif" alt="' . $topic['board']['name'] . '"/>' . $topic['link'] . ' — ' . $topic['poster']['link'] . ' | Comments: ' . $topic['replies'] . ' </div>';
?>
<?php
$new_topics = ssi_recentTopics(10, null, null, 'array');
foreach ($new_topics as $topic)
{
switch ($topic['board']['id'])
{
case 3:
echo '<div class="topic_list"><a href="" class="d_block">3D</a> ' . $topic['link'] . ' — ' . $topic['poster']['link'] . ' | Comments: ' . $topic['replies'] . ' </div>';
break;
case 1:
echo '<div class="topic_list"><a href="" class="d_block">WIP</a> ' . $topic['link'] . ' — ' . $topic['poster']['link'] . ' | Comments: ' . $topic['replies'] . ' </div>';
break;
default:
echo '<div class="topic_list"><img src="/Themes/flatline/images/post/xx.gif" alt="' . $topic['board']['name'] . '"/>' . $topic['link'] . ' — ' . $topic['poster']['link'] . ' | Comments: ' . $topic['replies'] . ' </div>';
}
}
-
And that got my attention, it could worth for you to add a language variable to handle that "Comments", otherwise it will show as "Comments" regardless of the language being used.