SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: goten22 on August 26, 2015, 06:48:57 PM

Title: Recen topics with variables for specific boards
Post 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

Title: Re: Recen topics with variables for specific boards
Post by: goten22 on August 28, 2015, 03:48:24 PM
Figured it out.

Code: [Select]
<?php
$new_topics
=ssi_recentTopics(10nullnull'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'] . ' &mdash; ' $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'] . ' &mdash; ' $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'] . ' &mdash; ' $topic['poster']['link'] . ' | Comments:  ' $topic['replies'] . ' </div>';

}
}
Title: Re: Recen topics with variables for specific boards
Post by: ♦ Ninja ZX-10RR ♦ on August 28, 2015, 09:27:09 PM
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...
Title: Re: Recen topics with variables for specific boards
Post by: goten22 on August 29, 2015, 07:54:40 AM
Sure, but I'm testing whole forum so even id boards are not final and I want to modify them quickly and easily. ;)
Title: Re: Recen topics with variables for specific boards
Post by: ♦ Ninja ZX-10RR ♦ on August 29, 2015, 08:38:37 AM
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.
Title: Re: Recen topics with variables for specific boards
Post by: ccbtimewiz on August 29, 2015, 04:41:40 PM
Here is a couple of ways I would have done it.

Code: [Select]
<?php

$zone_topics 
ssi_recentTopics(10null, array(3), 'array');
$wip_topics ssi_recentTopics(10null, array(1), 'array');
$remaining_topics ssi_recentTopics(10, array(13), null'array');

foreach (
$zone_topics as $topic)
echo '<div class="topic_list"><a href="" class="d_block">3D</a> ' $topic['link'] . ' &mdash; ' $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'] . ' &mdash; ' $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'] . ' &mdash; ' $topic['poster']['link'] . ' | Comments:  ' $topic['replies'] . ' </div>';

?>

Code: [Select]
<?php

$new_topics 
ssi_recentTopics(10nullnull'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'] . ' &mdash; ' $topic['poster']['link'] . ' | Comments:  ' $topic['replies'] . ' </div>';
break;
case 1:
echo '<div class="topic_list"><a href="" class="d_block">WIP</a> ' $topic['link'] . ' &mdash; ' $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'] . ' &mdash; ' $topic['poster']['link'] . ' | Comments:  ' $topic['replies'] . ' </div>';
}
}
Title: Re: Recen topics with variables for specific boards
Post by: ♦ Ninja ZX-10RR ♦ on August 30, 2015, 01:13:14 AM
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.
SimplePortal 2.3.8 © 2008-2024, SimplePortal