News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

SSI - eliminate recent topics from private boards

Started by Chias, February 07, 2006, 09:09:14 PM

Previous topic - Next topic

Chias

Okay, I fully understand how to use the RecentTopics SSI include, and it works
great on my website. What I'd like to do is not show recent topics from boards that are not accessible to guests (private). What parameters do I need to pass to make sure that these boards are ignored?

Thanks, and sorry if this has already been covered somewhere. I couldn't find reference to it anywhere.

kegobeer

I thought private boards or boards not accessible were automatically excluded.  Can you post a link to an example where this is happening?
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

Chias

Sure. You can see this page in action. This is not live on my site yet...but you'll notice that the board Staff Lounge is included...this board is not accessible to unregistered members, but it still appears in the list.

http://polyamoryonline.org/template.php

kegobeer

That board isn't listed for me.  Are you sure you aren't logged into your site?
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

Chias

Umm...okay, that's my bad...I was logged in, it doesn't show when logged out. How stupid do I feel now. Thanks anyway for the help. Since you're being so helpful...how exactly does the SSI news function work? How can I target specific boards, number of posts, character limits, etc?

Thanks again!

kegobeer

What news function?  ssi_news or ssi_boardNews?

If you look at the ssi_examples.php file, you'll see the SSI functions in action.  I always recommend tearing the code apart to see how the functions are called, and also examining the SSI.php file and looking at the function you want to use.  The parameters you can pass are listed in the main function.
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

Chias


kegobeer

If you can't figure it out, reply to this post.  We'll help you figure it out.
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

Chias

Okay, so if I want to use the SSI Recent Topics function but eliminate some of the displayed information, such as the board name or author, what parameters would I need to pass? I'm very leery of deleting or modifying lines of code when  I'm not entirely sure of the outcome.

kegobeer

You don't modify SSI at all.  You just call the function and return the array, manipulating it how you want, instead of letting SSI output the information.  For instance:

$posts = ssi_recentTopics(8, null, 'return');
foreach ($posts as $post)
{
  echo 'Post: <a href="', $post['href'], '">', $post['subject'], '</a><br>';
}


This code would call the ssi_recentTopics function, load it into the $posts variable, and then loop thru the array and print out the subject as a hyperlink.

Take a close look the ssi_recentTopics function, and look at the foreach code for printing out the recent topic information.  It's just a matter of figuring out what you want to see.
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

Chias

Okay, I understand a bit more now. I see where the variables are coming from, now I just have to disseminate the exact syntax needed to invoke the appropriate variables. Thanks for all of your help. I have this thread bookmarked so if I need to come back for more help from you I will.

Chias

Okay, I've looked at the SSI file, but I don't entirely understand the proper syntax for calling more than one function from the database. For instance, the above code works fine, but what if I want the authors name and date to appear...along with maybe a preview of the post itself? How would that work?

Thanks again, you've been a big help so far.

kegobeer

In the ssi_recentTopics function, look at the $posts[] array.  It lists all of the information you can access.
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

Chias

I understand the information as it's listed..I can see that 'poster' refers to the person posting, and that 'newtime' refers to the date posted (possibly). I sort of understand the variables....what I don't understand is how to code it. I've tried plugging additional variables into the code you gave me but it always returns parsing errors. Sorry, I'm just not horribly fluent in PHP yet.....learning though.

kegobeer

If you want to add a brief description, it would look like this:

$posts = ssi_recentTopics(8, null, 'return');
foreach ($posts as $post)
{
  echo 'Post: <a href="', $post['href'], '">', $post['subject'], '</a><br>
Description: ', $post['short_subject], '<br>';
}


You'll see plenty of examples of intermingling variables with HTML in SSI.php, ssi_examples.php, and pretty much any SMF file.  It's just a matter of getting accustomed to how it works.  I highly recommend visiting php.net and browsing thru the online documentation, and visiting your local library and flipping thru a few PHP books.  Best way to learn!
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

Chias

Thank you...I'm understanding more of it all the time. That last bit of code that you gave me returns an error though:

Parse error: parse error, unexpected '>' in /home/content/c/h/i/chias/html/template.php on line 14

Is there a typo in there maybe?

kegobeer

Yes.  This is the correct code:

$posts = ssi_recentTopics(8, null, 'return');
foreach ($posts as $post)
{
  echo 'Post: <a href="', $post['href'], '">', $post['subject'], '</a><br>
Description: ', $post['short_subject'], '<br>';
}


short_subject has to be enclosed in apostraphes - I simply forgot the closing one.
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

Chias

Thanks a lot for all of your help. I'll fiddle around with that code and see what I can come up with..it works great!

Chias

#18
I've managed to produce exactly the results I've been trying to achieve based on your input! Thanks again. Now, unfortunately, I need to specify these links to load on "top" instead of loading in the iframe I have them in. Is this possible?

Also, I've posted elsewhere in these forums regarding another issue, but as of yet have not gotten a response. Is there any way to post recent posts under board names on the main board index?

Like this:

Board name
recent post | recent post | recent post


Board name
recent post | recent post | recent post

Board name
recent post | recent post | recent post

Just curious. Thanks

kegobeer

iframe question: Put the code where you need it.

under board question: That would require editing your theme.  I'm sure it's possible, but I've never done it.

post elsewhere question: As for your other post, at least one day is customary, and a few days is not out of the question, before someone replies.
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

Advertisement: