News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

SSI Multiple Board News (ssi_multiBoardNews)

Started by vbgamer45, December 25, 2009, 01:57:08 AM

Previous topic - Next topic

vbgamer45

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:
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:
$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):
$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

JBlaze

Jason Clemons
Former Team Member 2009 - 2012

mira-san

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:

$parameters = array(
  'limit' => 5,
  'board' => array(2.0),
  'category' => array(1),
  'board_disp' => false,
  'category_disp' => false,
  'avatar' => 'left',
  'icon' => 'none',
);
ssi_multiBoardNews($parameters);

mira-san

I used this code and it works perfectly.

$parameters = array(
  'limit' => 5,
  'board' => array(2),
  'avatar' => 'left',
);
ssi_multiBoardNews($parameters);


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

ianus

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!

trzycha

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.

bayken37

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!


Yağız...

Hey Arantor,

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

It should be:
if ($parameters['output_type'] != 'echo')
return $return['topics'];

Yağız...

Oh, yeah you're right :) I never thought that.

Nevermind, thanks for this usefull mod ^^

MH-MINI

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

MH-MINI

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

Bijan641

I can't get this mod to return anything, even when I use the default return method.

Bijan641

$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.

Bijan641

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.

Bijan641

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.

Bijan641

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

Bijan641


Bijan641

Got an error:

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

Assuming you meant
<?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) { }

Bijan641


Advertisement: