Can SSI display a single post? (Answered: no)

Started by NFG, August 16, 2009, 12:42:53 AM

Previous topic - Next topic

NFG

I've been unable to avoid being 'the guy' for a friend's forum migration from PHPbb to SMF, since I encouraged the move...  I didn't realize however that a large part of his main site was built off the old forum, and though I've been able to get SSI to sort out most of the functionality, one little detail remains:

He has permanent links on his main page that bring users to a static page populated with information from a single post.  For example, "About us" might link to a nicely themed page displaying content from forum post #9933.  Unfortunately, the only way I can find to display a single post using SSI is to create a new sub-forum for every single one of these info pages, since the only relevent function SSI offers is the 'news' which would change the displayed post every time a new one is made...

I am not convinced my explanation is clear, so let's try this: If you wanted to display a single, known post rather than the latest post in a forum, how would you do it?

Arantor

Are you using SMF 1 or SMF 2? SMF 1 doesn't AFAIK have the ability to grab a single post in SSI though SMF 2 does, I believe.

Failing that you can always grab it from the DB manually, push it through the BBcode parser and display it yourself.
Holder of controversial views, all of which my own.


NFG

I'd actually figured I'd modify SSI instead, so that I can use the facilities that exist.  Just wanted to make sure I didn't start reinventing any wheels in case I'd missed something in SSI.

Arantor

Ah, so you're using SSI from SMF 1 then, yeah you'd have to modify that, or better: don't modify it and just use its facilities such as db_query() in your own code.
Holder of controversial views, all of which my own.


Kays

I just found this mod (when looking for something else) and it might be what you are looking for.

http://custom.simplemachines.org/mods/index.php?mod=751

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

NFG

That did work fine for me, thanks Kays.

I had to hack it up a bit, 'cause it refused to display a post without showing at least one reply, but that was relatively trivial.  Very happy now.  =)

Kays


If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

IchBin™

IchBin™        TinyPortal

carrerafan

Sorry for dragging up a very old post, but I didn't want to start a new thread for something that's (sort of) already here.

I'm having problems with doing this in SMF 2.

array ssi_boardNews ([int $board[, int $limit[, int $start[, int $length[, string $output_method]]]]])

It's the $start parameter, what's it expecting? I've tried both a topic ID and a message ID and it returns nothing, but I know the other parameters are fine because changing the start to 0 pulls through topics from the correct board. Should I be using a different function?
I currently have:

$array = ssi_boardNews(5.0,1,1071,650, 'array');

Thanks

IchBin™

Instead of opening up an old topic, it's better to just start your own and reference any other relevant topic.

Start is the limit you want to set. If you look at the code $start is what is set in the query where it limits the result set. You can leave it as null, or set it to the number you need to limit the query to only pull certain number of results. Length is the end of the limit.
IchBin™        TinyPortal

carrerafan

Thanks IchBin, the documentation says something completely different and that's why I'm a bit lost.

Parameter $start
Expected type: Integer
Description: The ID of a particular post to start with (otherwise the first result will be used)

Parameter $length
Expected type: Integer
Description: If specified, posts longer than this will be shortened and have "..." or a "Read More" link appended

If I set $start to 1, it returns the second newest topic's opening post. Length refers to the character count of the returned posts, that is working as I expected! I'm not sure it does what I want it to and i may have to look for something else to solve this issue.

thanks again.

IchBin™

Oops I thought length was the second parameter in the limit (it's actually $limit) sorry about that.

So yes, $length limits the amount of characters. But the $start could perhaps be worded better in that doc. It's not the id of the topic, but the number at which you want to start grabbing the result set. For example in the actual code you see this:
LIMIT ' . $start . ', ' . $limit,

The $start is the number at which record you want to start grabbing the results, then $limit is the amount of results you want to grab.

Say you have these records being returned.
record1
record2
record3
record4
record5

Now I do this on my query ---  LIMIT 3, 2

The first record it will grab is record3, then it will only grab 2 records. So you will only get record3 and record4. Hope that makes sense.
IchBin™        TinyPortal

Advertisement: