News:

Wondering if this will always be free?  See why free is better.

Main Menu

ssi_boardNews Multiple Boards

Started by Daniel15, April 08, 2007, 02:42:45 AM

Previous topic - Next topic

Daniel15

Link to Mod

ssi_boardNews Multiple Boards

This mod will modify ssi_boardNews so that multiple board IDs can be passed to it as an array.

How to use?
Instead of calling ssi_boardNews with a single number, call it with an array. For example:
echo ssi_boardNews(array(1,2,3));
will output the latest news from boards 1, 2 and 3.

Example script
Below is an example script, using the ssi_boardNews "array" output method. This allows you to format the output in whatever way you'd like to.

<?php
// Require SSI
require('SSI.php');

// Some variables. Change these to test this script :)
$boards = array(123); // Boards to use
$number 10// Number of items to return
$length 300// Return this number of characters, followed by "...".

// Get the news
$news_items ssi_boardNews($boards$numbernull$length'array'); // array(boards), number of items, item to start at, number of characters, output method
// Loop through all items
foreach ($news_items as $news)
{
// Output this item
echo '
<div>
<a href="'
$news['href'], '">'$news['icon'], '</a> <b>'$news['subject'], '</b>
<div class="smaller">'
$news['time'], ' by '$news['poster']['link'], ' in '$news['board']['link'], '</div>

<div class="post" style="padding: 2ex 0;">'
$news['body'], '</div>

'
$news['link'], $news['locked'] ? '' ' | ' $news['comment_link'], '
</div>'
;

// If it isn't the last item, output a <hr />
if (!$news['is_last'])
echo '
<hr style="margin: 2ex 0;" width="100%" />'
;
}
?>



Changelog
Version 1.0
- Initial release
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

sanax

Great mod, Daniel!
I have a blond moment here, where do I add the the above script? I would like to use one 'topic' as board news editable by the mods

TIA

samozin

#2
this mod is kwel
thats the one i was waiting for
but
look at this
Parse error: syntax error, unexpected $end, expecting ',' or ';' in /home/the site name/public_html/forum/SSI.php on line 1883
i think this error  comming from using ur latest 2 mods together ..

Daniel15

Quote from: samozin on April 08, 2007, 08:05:03 PM
look at this
Parse error: syntax error, unexpected $end, expecting ',' or ';' in /home/the site name/public_html/forum/SSI.php on line 1883
i think this error  comming from using ur latest 2 mods together ..
Could you please attach your SSI.php file here? I'll try to see what's wrong with it.
SSI.php should be much longer than 1883 lines; my one is 2155 lines.

Quote from: sanax on April 08, 2007, 11:02:13 AM
Great mod, Daniel!
I have a blond moment here, where do I add the the above script? I would like to use one 'topic' as board news editable by the mods

TIA
I think you're misunderstanding this mod?
Basically, SMF has a function called "ssi_boardNews". This allows you to show topics from a certain board on any page you like (such as on your website). See the "Board News Function" of ssi_examples.php for an example (ssi_examples.php comes with SMF, eg. http://www.simplemachines.org/community/ssi_examples.php). However, SMF's inbuilt one only allows one board to be used for the news. This mod simply allows you to use multiple boards. This is useful if you have a few news boards (each with a different focus), and you want to show news from all of them.

As for the script above; that's just an example script. You may save it in your forum's directory with any file name, and it will show you an example of the output produced by ssi_boardNews.

I hope this helps you :)
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

mkress

thats a great mod!!!
many THANKS!!

perhaps you can help me with a problem.

i want to display a pagination on bottom, for example:
Page [1]..[8]

i know that it's  possible to do that with the $start-variable, but i do not know if there is an variable that puts out the number of all news in the $board-variable so that i know how many pages i should print.

Daniel15

The way that I do pagination is issue a seperate query to get the number of topics. On my website (www.daniel15.com), I do something like:

<?php
require('forum/SSI.php');

// Number of pages
$result db_query("
SELECT COUNT(ID_TOPIC)
FROM 
{$db_prefix}topics
WHERE ID_BOARD = 2"
__FILE____LINE__);
list (
$newsNumber) = mysql_fetch_row($result);
mysql_free_result($result);

// Pagination - List of page numbers
$pageIndex constructPageIndex('http://' $_SERVER['HTTP_HOST'] . '/' $_SERVER['PHP_SELF'] . '?start=%d', &$_REQUEST['start'], $newsNumber10true);

// Actual items
$newsItems ssi_boardNews(210$_REQUEST['start'], 0'array'); 

// Page numbers
echo '
<div align="right">'
$pageIndex'</div>';

$alternate "windowbg1";
foreach(
$newsItems as $newsItem)
{
echo '
<div class="'
$alternate'">
<b>'
$newsItem['icon'], ' '$newsItem['time'], ' - <a href="'$newsItem['href'], '">'$newsItem['subject'], '</a> by '$newsItem['poster']['link'], '</b><br />
'
$newsItem['body'], '<br />
'
$newsItem['link'], ' | '$newsItem['new_comment'], '
</div><hr /><br />'
;

 $alternate = ($alternate == 'windowbg1') ? 'windowbg2' 'windowbg1';
}

// Page numbers
echo '
<div align="right">'
$pageIndex'</div>';
?>



Replace "2" with the board ID. If you're using multiple boards (with this mod, I guess you are ;)), replace
WHERE ID_BOARD = 2
With
WHERE ID_BOARD IN (2, 3, 4)

(replace 2, 3, 4 with a list of the board IDs).
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

mkress


tsmalmbe

I coded a pretty similar thing a few weeks ago. My version checks the permissions aswell. Does this one check permissions?
..:: http://www.kontrollrummet.com - Studio och musik ::.. RSS?

mkress

no it does not - it only checks if a guests can view a board
pagination does no check

tsmalmbe

Permissions are nice. Just think of news for different membergroups. Or, like I have it in conjunction with the "ignore boards"-mod, a system that people can pick and choose from my newsboards which they want so see on the frontpage.
..:: http://www.kontrollrummet.com - Studio och musik ::.. RSS?

Daniel15

tsmalmbe, permissions would be good, but I only coded this to extend the ssi_boardNews function so it allows multiple boards... I didn't add any other extra functionality to it (I try to keep mods simple :))
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

gregh

thanks for a great mod, I have one query, my error log is showing thousands of errors around is_last when I run this (although it appears to run fine)

A section of the error log is below:

client 75.111.158.11] PHP Notice: Undefined index: is_last in /var/www/vhosts/pocketpcsoft.net/httpdocs/index.php on line 621, referer: http://www.google.com/search?source=ig&hl=en&q=pocket+pc+programs&btnG=Google+Search
[client 75.111.158.11] PHP Notice: Undefined index: is_last in /var/www/vhosts/pocketpcsoft.net/httpdocs/index.php on line 621, referer: http://www.google.com/search?source=ig&hl=en&q=pocket+pc+programs&btnG=Google+Search
[client 75.111.158.11] PHP Notice: Undefined index: is_last in /var/www/vhosts/pocketpcsoft.net/httpdocs/index.php on line 621, referer: http://www.google.com/search?source=ig&hl=en&q=pocket+pc+programs&btnG=Google+Search
[client 75.111.158.11] PHP Notice: Undefined index: is_last in /var/www/vhosts/pocketpcsoft.net/httpdocs/index.php on line 621, referer: http://www.google.com/search?source=ig&hl=en&q=pocket+pc+programs&btnG=Google+Search
[client 75.111.158.11] PHP Notice: Undefined index: is_last in /var/www/vhosts/pocketpcsoft.net/httpdocs/index.php on line 621, referer: http://www.google.com/search?source=ig&hl=en&q=pocket+pc+programs&btnG=Google+Search
[client 75.111.158.11] PHP Notice: Undefined index: is_last in /var/www/vhosts/pocketpcsoft.net/httpdocs/index.php on line 621, referer: http://www.google.com/search?source=ig&hl=en&q=pocket+pc+programs&btnG=Google+Search
[client 75.111.158.11] PHP Notice: Undefined index: is_last in /var/www/vhosts/pocketpcsoft.net/httpdocs/index.php on line 621, referer: http://www.google.com/search?source=ig&hl=en&q=pocket+pc+programs&btnG=Google+Search
[client 75.111.158.11] PHP Notice: Undefined index: is_last in /var/www/vhosts/pocketpcsoft.net/httpdocs/index.php on line 621, referer: http://www.google.com/search?source=ig&hl=en&q=pocket+pc+programs&btnG=Google+Search

This is line 621&nbsp; from my php (taken from your example above)

      if (!$news['is_last'])
      
thanks,

Greg

Daniel15

Argh... My bad :P
Change

if (!$news['is_last'])


To:

if (!empty($news['is_last']))

:)
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

ormuz

After upgrade my host from php4 to php5 the SSI function crash.... the topic content nerver was showed again!

Sorry for my poor eglish, to have a better look please see my site! www.festivais.org

I use a joomla module based on this code, is similar to daniel15 code...
<?php
/**
* SMForumNews - A Module that displays news pulled from a Simple Machines forum
* @version 1.1
* @package SMForumNews
* @copyright (C) 2004 by Ben - All rights reserved!
**/

  
defined'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  
$forum  $params->def'forum''1' );
  
$limit  $params->def'limit''5' );
  
$length  $params->def'length''' );
  
$showicon  $params->get'icon''1' );
  
$showpostinfo  $params->get'postinfo''1' );
  
$showlink  $params->get'link''1' );
  
$moduleclass_sfx  $params->get'moduleclass_sfx''' );


$array ssi_boardNews($forum$limitnull$length'array');

foreach (
$array as $news)
{
  if (
$showicon) {
    echo 
'<div style="position: static; width:  99%; text-align: left; vertical-align: bottom;"><b>'$news['icon'], ' '$news['subject'], '</b></div>';
  }
  else  {
    echo 
'<div style="position: static; width:  99%; text-align: left; vertical-align: bottom;"><b>'$news['subject'], '</b></div>';
  
  }
  
  if (
$showpostinfo) {
    echo 
'<div style="position: static; width:  99%; text-align: left; vertical-align: bottom;"><span class="smaller">'$news['time'], ' '$txt[525], ' '$news['poster']['link'], '</span><br /></div>';
  }
  
  echo 
'<br /><div style="position: static; width:  99%; text-align: left; vertical-align: bottom;">'$news['body'], '<br /><br /></div>';

  if (
$showlink) {
    echo 
'<div style="position: static; width:  99%; text-align: right; vertical-align: bottom;">'$news['link'], ' | '$news['new_comment'], '<br /><br /></div>';
  }

if (!
$news['is_last'])
echo 
'
<hr width="100%" />
<br />'
;
  }

?>

Serenity

is it possible to make this work with hidden boards?

Chantal Matar

Is a board meant to appear?  I have installed it and the other Board News Mod and nothing is showing up.  If I put news in the News box then it will show up in the NewsFeeder otherwise it's not taking the topic titles from the Board?

I don't understand.

hailstone

do you have this kind of module for joomla? i tried some codes for multiple boards but only 1 is showing :)

andrewteg

Quote from: Serenity on July 13, 2007, 04:51:34 PM
is it possible to make this work with hidden boards?

Serenity, what method are you using to hide a board? I updated this code a bit to make the boards parameter optional and keep the output on the same page if you click on a board link and my next step is to hide boards and see if it works on those hidden boards so I can have a board hidden on index if I can figure it out... I figure I may as well help both of us if I can :)

Jim R

Any idea on when this is going to be updated for 2.0?  I tried porting it over, but there appears to be differences in how databases are queried and likely other changes I don't recognize how to alter.

minos

hi help me please im making a html portal for ,my forum and  i would like to make tgis with  news


show topic from selected boards  that ok i se <?php ssi_boardNews(array(1,2,3)) ?>

but i cant  use maximum topics to show i wpild like to grab only 15 or 20 topics ...

and if its possible show a  pagination at the top and bottom..


can you help me with the code im not good for this stuff

thanks

Advertisement: