Advertisement:

Author Topic: SSI Multiple Board News (ssi_multiBoardNews)  (Read 70329 times)

Online vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 21,953
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
SSI Multiple Board News (ssi_multiBoardNews)
« on: December 25, 2009, 01:57:08 AM »
Link to Mod

SSI Multiple Board News (ssi_multiBoardNews)


Original Author: Arantor
SMF Version: 2.0.x and 1.1.X
Mod Version: 2.0

Description:
One of the functions built into SMF's SSI.php is the ability to get topics from a board in order to use it to display 'news', the venerable ssi_boardNews.

After receiving several customisation requests though, I finally decided to write a more powerful version, ssi_multiBoardNews.

You still have to use SSI.php, but you can substitute calls to this instead of ssi_boardNews, but as I'll explain in a moment, it isn't just a list of options like:
Code: [Select]
ssi_multiBoardNews(10, x, y, z, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
There are just too many options, so instead, you build an array first, simply because of the number of options this function has, it's not really viable to do anything else.

You call it: ssi_multiBoardNews($parameters), where $parameters contains the following:

$parameters['board'] - an integer board id or array of board ids from which to get topics
$parameters['board_disp'] - true/false, display the board name in output, default true
$parameters['category'] - an integer category id, or array of category ids from which to get topics
$parameters['category_disp'] - true/false, display the category name in out, default false
$parameters['limit'] - number of topics to get, default 5
$parameters['start'] - number of topics to skip over, for pagination, default 0 (start at the most recent)
$parameters['length'] - optional maximum length of topic first posts, in characters, defaults to no limit
$parameters['perms_override'] - true/false (default false), whether to override the permissions check; by default guests have to be able to see the board - this allows you to have a hidden 'news' board so that only admins can see it, and allow it to be viewed by guests.
$parameters['icon'] - optional, limits the scope to one or more icons.
$parameters['attachments'] - whether to display attachments or not, supports any one of the following string options: (NB. This still uses the main attachments system. The board would have to have permissions for guests to be able to view attachments.)

    'none', the default, does not show attachments
    'linkonly', displays only links to the attachments
    'thumbnail', displays image thumbnails and links them to the attachments
    'inline', displays the full images from image attachments, links to other attachments

$parameters['avatar'] - whether to display the poster's avatar or not, supports any one of the following string options:

    'none', the default, display no avatar
    'left', display it to the left of the post
    'right', display it to the right of the post

$parameters['feed'] - displays the appropriate feed links. Unlike the others, this is an array of strings field. See below.

    'none', the default, displays no feed
    'rss', displays the RSS feed link for the board(s) you select
    'atom', displays the ATOM feed link for the board(s) you select
    'rdf', displays the RDF feed link for the board(s) you select

    To display multiple feeds, enter as such:
    $parameters['feed'] = array('rss', 'atom');
    If SMF supports different things later on, this can be used to expand them without serious recoding.

$parameters['output_type'] - either 'echo' or 'array'. 'echo', default, outputs normally, 'array' returns to your code (note that avatars and attachments are only returned is $parameters['avatar'] and $parameters['attachments'] are set to something other than avatar type 'none' and attachment type 'none' for performance reasons.


Some examples:
Fetching the most recent 10 topics from across boards 1, 2 and 5:
Code: [Select]
$parameters = array(
  'limit' => 10,
  'board' => array(1,2,5),
);
ssi_multiBoardNews($parameters);

To get 15 topics from boards 1 and 2, plus all the boards in category 12, displaying the avatars on the left of the posts, and displaying both the board and category name in the output too, oh and limiting it to only thumbup posts (using the thumbs up icon):
Code: [Select]
$parameters = array(
  'limit' => 15,
  'board' => array(1,2),
  'category' => array(12),
  'board_disp' => true,
  'category_disp' => true,
  'avatar' => 'left',
  'icon' => 'thumbup',
);
ssi_multiBoardNews($parameters);

Why Not Visit:
http://www.smfhacks.com
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,160
  • Gender: Male
    • @fragicide on Twitter
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #1 on: December 25, 2009, 01:59:17 AM »
Congrats on another approved mod spammer :P
Jason Clemons
Former Lead Customizer/Support Specialist
Twitter | Facebook | Instagram

Offline mira-san

  • Semi-Newbie
  • *
  • Posts: 52
  • Gender: Female
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #2 on: December 25, 2009, 05:24:49 PM »
Thank you very much, I was waiting for this mod ;D
I have a small question:
-How can I view the last 5 news of the section n°: 2.0, cat 1, with the avatar display on the left in my website index.php?

I have tried this in my index.php but it doesn't work:
Code: [Select]
$parameters = array(
  'limit' => 5,
  'board' => array(2.0),
  'category' => array(1),
  'board_disp' => false,
  'category_disp' => false,
  'avatar' => 'left',
  'icon' => 'none',
);
ssi_multiBoardNews($parameters);

Offline mira-san

  • Semi-Newbie
  • *
  • Posts: 52
  • Gender: Female
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #3 on: December 25, 2009, 05:42:34 PM »
I used this code and it works perfectly.
Code: [Select]
$parameters = array(
  'limit' => 5,
  'board' => array(2),
  'avatar' => 'left',
);
ssi_multiBoardNews($parameters);

Once again, Thank you so much for this fabulous mod. :)

Offline ianus

  • Jr. Member
  • **
  • Posts: 391
    • Firopolis
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #4 on: December 26, 2009, 10:56:05 AM »
Greetings! and Great!!

A while ago I asked for a solution to grab only threads which have a unique icon. (Change SSI function or create a new one to grab specific threads.)

I struggle around with the new SSI to reproduce the changes and now you offer everything I need.

Thanks a lot for this modification!

Offline trzycha

  • Semi-Newbie
  • *
  • Posts: 22
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #5 on: December 28, 2009, 03:55:04 PM »
Thanks
Will $parameters[ 'icon'] display only 1 post, or any other posts from topic that are marked with post icon? It would be great if it display all posts from topic  that are marked with a post icon.

Offline bayken37

  • Semi-Newbie
  • *
  • Posts: 21
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #6 on: December 30, 2009, 10:26:20 PM »
I've added this mod to my SSI.php file like that page says, but I keep getting the following error : "Parse error: parse error, unexpected '}' in /home/content/b/a/y/bayken37/html/forum/SSI.php on line 1974"

I re-installed the SMF package, but got the same thing.  Am I doing something wrong?

Thanks for any help!

Offline bayken37

  • Semi-Newbie
  • *
  • Posts: 21
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #7 on: December 30, 2009, 10:35:43 PM »
Here we are.

Offline Yağız...

  • SMF Super Hero
  • *******
  • Posts: 10,811
  • Gender: Male
    • MMO Browser
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #8 on: January 01, 2010, 06:00:34 PM »
Hey Arantor,

I have found a bug :)
When you use 'output_method' => 'array', the result returns blank. It's because of this:
Code: [Select]
if ($parameters['output_type'] != 'echo')
return $return;
It should be:
Code: [Select]
if ($parameters['output_type'] != 'echo')
return $return['topics'];

Offline Yağız...

  • SMF Super Hero
  • *******
  • Posts: 10,811
  • Gender: Male
    • MMO Browser
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #9 on: January 01, 2010, 06:15:03 PM »
Oh, yeah you're right :) I never thought that.

Nevermind, thanks for this usefull mod ^^

Offline MH-MINI

  • Jr. Member
  • **
  • Posts: 237
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #10 on: January 04, 2010, 12:10:04 AM »
Hi, I'm using SMF 2.0 RC2 and I get the following error from Package manager when I try to install this mod.

1.     Execute Modification     ./SSI.php     Test failed
      1.    Replace    ./SSI.php    Test successful
      2.    Replace    ./SSI.php    Test failed
      3.    Replace    ./SSI.php    Test failed
      4.    Add After    ./SSI.php    Test failed
      5.    Add After    ./SSI.php    Test failed

What is the problem here?

Thanks

Offline MH-MINI

  • Jr. Member
  • **
  • Posts: 237
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #11 on: January 04, 2010, 02:51:25 AM »
Yes you were correct. Sorry about that.

One quick question though. By default it says that it will show the last 5 posts for boardnews. I was wondering how I could make this indefinite?

Thanks

Offline Bijan641

  • Semi-Newbie
  • *
  • Posts: 55
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #12 on: January 15, 2010, 08:04:09 PM »
I can't get this mod to return anything, even when I use the default return method.

Offline Bijan641

  • Semi-Newbie
  • *
  • Posts: 55
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #13 on: January 15, 2010, 08:11:59 PM »
Code: [Select]
$parameters = array(
                'limit' => 1,
                'board' => array(13),
                'start' => 0,

            );

            ssi_multiBoardNews($parameters);

This is what I have. I was trying to return it to an array but when that wasn't working I just tried it standard and still got nothing.

Offline Bijan641

  • Semi-Newbie
  • *
  • Posts: 55
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #14 on: January 15, 2010, 08:40:14 PM »
Yes it is. I've displayed posts from this forum using other SSI functions, but this one is much more flexible for what I want to do.

Offline Bijan641

  • Semi-Newbie
  • *
  • Posts: 55
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #15 on: January 15, 2010, 09:04:09 PM »
I'm using 1.1.11 and the latest version of the mod.

As for the errors in the log, I would have no idea what to even look for really. I'm looking at it and there are thousands of errors.

Offline Bijan641

  • Semi-Newbie
  • *
  • Posts: 55
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #16 on: January 15, 2010, 09:23:57 PM »
Parse error: syntax error, unexpected '=', expecting ')' in /homepages/12/d210086393/htdocs/forum/ssi_test.php on line 3

Offline Bijan641

  • Semi-Newbie
  • *
  • Posts: 55
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #17 on: January 15, 2010, 09:33:57 PM »
The output is nothing.

http://www.dotswoof.com/forum/ssi_test.php

The link in case you need it.

Offline Bijan641

  • Semi-Newbie
  • *
  • Posts: 55
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #18 on: January 15, 2010, 09:43:39 PM »
Got an error:

Parse error: syntax error, unexpected ';', expecting ')' in /homepages/12/d210086393/htdocs/forum/ssi_test.php on line 4

Assuming you meant
Code: [Select]
<?php require('SSI.php');
$parameters = array(
  
'board' => array(13),
  
'output_type' => 'array'
);
$array ssi_multiBoardNews($parameters);
var_dump($array);
?>

When I did that, I get:

array(0) { }

Offline Bijan641

  • Semi-Newbie
  • *
  • Posts: 55
Re: SSI Multiple Board News (ssi_multiBoardNews)
« Reply #19 on: January 15, 2010, 10:04:30 PM »
array(1) {
  • => string(10) "posts_fail" }