Customizing ssi_boardNews()

Started by aneef88, May 07, 2010, 12:52:27 AM

Previous topic - Next topic

aneef88

I have been looking around the boards trying to find my answer before posting a topic of my own, and I found a topic created that covers almost all of what I am trying to do, but doesn't work quite right for me.  That post is located here

What I am trying to do is customize the way the board_news appears on the main page of my website.  I found this code:
<div>
<?php

$array
= ssi_boardNews(2, 1, null, 2000, 'array');

foreach(
$array as $post) {
 echo
' <h1>', $post['subject'], '</h1>
   <h2>Posted by '
, $post['poster']['link'], ' at ', date('G:i \o\n l, F j, Y', $post['timestamp']), '</h2>
   <p>'
, $post['body'], '</p>
   '
, $post['comment_link'];
}

?>
</div>


But I have not modified my SSI.php and do not need to use board_news as an array.  I know enough to get myself in trouble but not enough to fix it!  ;D

Where I believe it is incorrect for me is at the: foreach($array as $post) because I am not using it as an array, and I do not know what to put there to get the changes to show up correctly.

The rest of the code looks exactly like what I want to do, for the subject put it as a <h1>, posted by, date, etc as <h2>, and then the body as a <p>

Any help in guiding me in the right direction for this would be greatly appreciated.

Thanks,
Arthur

Arantor

Um, you ARE using it as an array - since the last parameter is array, not echo...

I'd like to help more but need to know what version of SMF you're using so I can check the rest of the parameters are right.
Holder of controversial views, all of which my own.


aneef88

Thanks for the reply, the verson of SMF I am using is 1.1.11

I wasn't positive about the coding I found but it definitily looked similar to what I wanted to do.

Thanks,
Arthur

Arantor

This will get you the most recent topic in board 2, the first 2000 characters of it.

What *exactly* are you trying to do?
Holder of controversial views, all of which my own.


aneef88

Sorry I didn't make that more clear in my original post  :-[

I want to display the first board on my forums to my homepage for news, and want to format how the text is displayed so it better matches the rest of my website.

Arantor

Right, and that still doesn't tell me how you want it laid out, how many topics you want, whether you even want boardNews; as that posts the first post of each topic - like I set up on http://www.emeraldeditor.com/ so so long ago. (That's a basic use of ssi_boardNews right there)
Holder of controversial views, all of which my own.


aneef88

Okay let me see if I can explain this better, I apologize for being so difficult  :-[

I have an Announcements board, it is the first one on my forum.  I want to display the first post of the 5 most recent topics of that board on the homepage of my website.
For those topics being displayed I want to format them as following:

<h1>Topic Title<h1>
<h2>Date, Time, Posted By</h2>
<p>Body Text</p>
<h3># of comments | Write Comment</h3>

Thanks,
Arthur

aneef88

Well I managed to figure out most of what I am trying to do.

I edited SSI.php and changed the ssi_boardNews $output_method to 'array' and then used the code:

<div>
<?php

$array
= ssi_boardNews();

foreach(
$array as $post) {
 echo
' <h1>', $post['subject'], '</h1>
   <h2>Posted by '
, $post['poster']['link'], ' at ', date('G:i \o\n l, F j, Y', $post['timestamp']), '</h2>
   <p>'
, $post['body'], '</p>
   '
, $post['comment_link'];
}

?>
</div>


I have one final question.

Where I have $array = ssi_boardNews(); I want to define the board as the first public board, and set the limit to the 5 most recent topics.

I try setting ssi_boardNews(1, 5); but it displays the 5 most recent topics from the second public board on the forums, not the first (which is the one I want it to use.)

Thanks,
Arthur

Arantor

Well, the first number controls the board. To find this out look at the URL of the board - ?board=1.0 means board 1.
Holder of controversial views, all of which my own.


aneef88

Quote from: Arantor on May 08, 2010, 06:52:18 AM
Well, the first number controls the board. To find this out look at the URL of the board - ?board=1.0 means board 1.

Thanks, I found the correct board ID and everything works great now!

Marking this as solved, thanks again!

Arthur

Advertisement: