Author Topic: SSI Topics and Replies  (Read 16047 times)

Offline tyty1234

  • Administrator
  • *****
  • Posts: 16
    • View Profile
    • tyty1234's SMF Site
  • SMF Version: 2.0 Gold
SSI Topics and Replies
« on: June 15, 2011, 11:37:04 PM »
id:SSITopicSSI Topics and Replies

Original Author: Daniel15
Currently Developed by: tyty1234
Current Version: 2.0
Compatible With: SMF 2.0


Summary
This mod adds a new SSI function that allows you to grab a topic and its replies.

Usage
Basic usage:
Code: [Select]
<?php ssi_topic(int $topicint $num_replies); ?>
$topic - The topic id for the topic you want to grab.
$num_replies - The number of replies you would like to show (provides a "more replies" link if there are more comments than the amount you limit).

Read reply below for advanced usage.

Installation
This mod should be installed using the Package Manager. No manual edits should be necessary, but if it comes to that resort, please use the Package Parser.

Changelog
What's new in this version?
Released for SMF 2.0
Dropped SMF 1.1.x compatibility.
Full re-write of mod.
Ability to grab attachments, and use of negative offsets in $start variable to get last # of replies.
Replaced page index with a "more replies" link (customizable).
« Last Edit: June 23, 2011, 12:56:42 PM by tyty1234 »
tyty1234
Admin of tytyweb.net

Offline tyty1234

  • Administrator
  • *****
  • Posts: 16
    • View Profile
    • tyty1234's SMF Site
  • SMF Version: 2.0 Gold
Re: SSI Topics and Replies
« Reply #1 on: June 23, 2011, 10:28:19 PM »
Function Reference

Description
This function grabs all posts associated with $topic, and returns an array of the first post (topic) and its replies. This function has the ability to grab attachments associated with the posts that it returns when $get_attachments is set to true. The function limits itself to the first $num_replies of replies unless you choose to get the last # of replies to $topic (read about the $start parameter below). When called, the function will display the topic and the first 10 replies by default.

Full Usage
Code: [Select]
<?php ssi_topic(int $topicint $num_repliesint $startstring $more_replies_txtbool $override_permsbool $get_attachmentsstring $output_method); ?>
Parameters
$topic (integer) (required)
Insert the topic ID you would like the function to grab. Usually this can be found with the ?topic request in the url when viewing a topic. If you're using Pretty URLs, the topic ID can be found by clicking the permalink to the first post, and it will give you a msg# in the url.

$num_replies (integer) (optional)
The number of replies you want the function to grab. If there are more replies in the topic than the number you define here, it will add a "more replies" link to array that you can customize with $more_replies_txt.

$start (integer) (optional)
By default, this will grab all replies when $start is zero. The integer "1" will grab all the replies, starting from the SECOND reply. The integer "2" will grab all replies starting from the THIRD. The integer "3" ... FOURTH ... "4" ... FIFTH ... etc. You can define a negative offset to grab the last # of replies. For example, "-1" will grab the last reply, "-2" will grab the last 2 replies, and so on. If a negative offset is used however, $num_replies will be ignored.

$more_replies_txt (string) (optional)
By default, this is "More Replies". You can set this to whatever you want and when there are more replies than the amount defined in $num_replies, it will display link to the next comment, and it will display what you define for this variable, or if you don't put anything, it will display "More Replies".

$override_perms (boolean) (optional)
By default, this is false. When false, the function will grab the topic and replies only if the user can see the board the topic is in. For example, if you have a board private to specific users, and you're grabbing a topic from that board, the users that aren't specified will NOT be able to see the topic you grab. If this is true however, then those users that cannot see the board the topic is located in, WILL be able to see the topic and its replies. If you are okay with that, you may set this variable to true.

$get_attachments (boolean) (optional)
By default, this is false. If you wish to load the attachments that are attached to the topic and replies, set this to true. This will add an "attachments" key to the post array. If no attachments are found, then the array key will not be created. For information on what this array returns, see "Output Information" below.

$output_method (string) (optional)
By default, this is "echo", which will display your topic and replies using a simple blank template. To use your own template, you will have to design the template yourself, and set this to "array" or "return". For information on what this function returns as an array, see "Output Information" below.

Examples

To get only the first post of the topic...
Code: [Select]
<?php
// Get SSI.
require('SSI.php');

// Grab topic id 7, with no more than 10 replies, start from first reply,
// use default "more replies" text, use default perms, don't include attachments,
// and return an array, do not echo.
$topic ssi_topic(7100nullfalsefalse'array');

echo 
'
<table border="0">
<tr>
<td valign="top" nowrap="nowrap">
'
$topic['first_post']['link'], '
<div style="font-size: small">'
$topic['first_post']['time'], ' '$txt['by'], ' '$topic['first_post']['poster']['link'] , '</div>
<div style="padding: 2ex 0;">
'
$topic['first_post']['body'], '
</div>
</td>
</tr>
</table>'
;
?>


To get the replies to a topic and customize "more replies" link...
Code: [Select]
<?php
// Get SSI.
require('SSI.php');

// Grab topic id 7, with no more than 5 replies, start from first reply,
// say "More Comments" for "more replies", use default perms, don't include attachments,
// and return an array, do not echo.
$topic ssi_topic(750'More Comments'falsefalse'array');

echo 
'
<table border="0">
<tr>
<td valign="top" nowrap="nowrap">
<strong>Replies to '
$topic['first_post']['subject'], '</strong>
</td>
</tr>'
;

// Go through each reply, and display it.
foreach ($topic['replies'] as $reply)
echo '
<tr>
<td valign="top" nowrap="nowrap">
<div style="font-size: small">'
$txt['posted_by'], ' '$reply['poster']['link'] , ' '$txt['on'], ' '$reply['time'], '</div>
<div style="padding: 2ex 0;">
'
$reply['body'], '
</div>
</td>
</tr>'
;

// If there were more than $num_replies posts, then show the "more reples" link.
if (isset($topic['more_replies_link']))
echo '
<tr>
<td valign="top" nowrap="nowrap">
'
$topic['more_replies_link'], '
</td>
</tr>'
;

echo 
'
</table>'
;
?>


To get the attachments of the first post to a topic...
Code: [Select]
<?php
// Get SSI.
require('SSI.php');

// Grab topic id 7, with no more than 10 replies, start from first reply,
// use default "more replies" text, use default perms, include attachments,
// and return an array, do not echo.
$topic ssi_topic(7100nullfalsetrue'array');

echo 
'
<table border="0">
<tr>
<td valign="top" nowrap="nowrap">
'
$topic['first_post']['link'], '
<div style="font-size: small">'
$topic['first_post']['time'], ' '$txt['by'], ' '$topic['first_post']['poster']['link'] , '</div>
<div style="padding: 2ex 0;">
'
$topic['first_post']['body'], '
</div>'
;

// If there are attachments, list them.
if (isset($topic['first_post']['attachments']))
{
echo '
<div>Attachments:'
;

foreach ($topic['first_post']['attachments'] as $attachment)
echo ' <a href="'$attachment['href'], '">'$attachment['filename'], '</a>';

echo '</div>';
}

echo 
'
</td>
</tr>
</table>'
;
?>


To get the last 5 replies made to the topic...
Reminder: $num_replies will be IGNORED
Code: [Select]
<?php
// Get SSI.
require('SSI.php');

// Grab topic id 7, get last 5 replies, use default perms, 
// don't include attachments, and return an array, do not echo.
// $num_replies (10) is ignored.
$topic ssi_topic(710, -5nullfalsefalse'array');

echo 
'
<table border="0">
<tr>
<td valign="top" nowrap="nowrap">
<strong>Last 5 Replies to '
$topic['first_post']['subject'], '</strong>
</td>
</tr>'
;

// Go through each reply, and display it.
foreach ($topic['replies'] as $reply)
echo '
<tr>
<td valign="top" nowrap="nowrap">
<div style="font-size: small">'
$txt['posted_by'], ' '$reply['poster']['link'] , ' '$txt['on'], ' '$reply['time'], '</div>
<div style="padding: 2ex 0;">
'
$reply['body'], '
</div>
</td>
</tr>'
;

echo 
'
</td>
</tr>
</table>'
;
?>


Output Information
$topic_data holds all the information for the topic and replies. If $output_method is not "echo", the function will return an array of arrays. Below is more information on each array key.
$topic_data['first_post']['id']
Returns the ID of the post/reply.
$topic_data['first_post']['board']['id']
Returns the board ID of the board the post is in.
$topic_data['first_post']['board']['name']
Returns the name of the board the post is in.
$topic_data['first_post']['board']['href']
Returns the url only of the board the post is in.
$topic_data['first_post']['board']['link']
Displays the clickable link to the board the post is in.
$topic_data['first_post']['topic']
Returns the topic ID the post belongs to.
$topic_data['first_post']['poster']['id']
Returns the ID of the poster of the post/reply.
$topic_data['first_post']['poster']['name']
Returns the user name of the poster of the post/reply.
$topic_data['first_post']['poster']['href']
Returns the url only of the poster of the post/reply.
$topic_data['first_post']['poster']['link']
Displays the clickable link of the poster of the post/reply.
$topic_data['first_post']['subject']
Returns the subject of the post.
$topic_data['first_post']['short_subject']
Returns the short version of the subject of the post.
$topic_data['first_post']['preview']
Returns the preview of the post.
$topic_data['first_post']['body']
Displays the full content of the post.
$topic_data['first_post']['time']
Returns the date and time when the post was posted.
$topic_data['first_post']['timestamp']
Returns the UNIX timestamp of when the post was posted.
$topic_data['first_post']['href']
Returns the url only of the post.
$topic_data['first_post']['link']
Displays the clickable link to the post.
$topic_data['first_post']['new']
This determines if the post has been read or not. If 0 is returned, it is false or empty. If 1 is returned, it is true.
$topic_data['first_post']['is_new']
This determines if the post is new or not. If 0 is returned, it is false or empty. If 1 is returned, it is true.
$topic_data['first_post']['new_from']
This determines if the post is new from a post ID. If 0 is returned, it is false or empty. If 1 is returned, it is true.
$topic_data['first_post']['attachments'][$attach_id]['filename'] ($get_attachments must be true)
Returns the name of the file that was attached.
$topic_data['first_post']['attachments'][$attach_id]['filesize'] ($get_attachments must be true)
Returns the size of the file that was attached.
$topic_data['first_post']['attachments'][$attach_id]['downloads'] ($get_attachments must be true)
Returns the number of downloads the file attached had.
$topic_data['first_post']['attachments'][$attach_id]['href'] ($get_attachments must be true)
Returns the url only of the attachment.
$topic_data['first_post']['attachments'][$attach_id]['link'] ($get_attachments must be true)
Displays the clickable link of the attachment.
$topic_data['first_post']['attachments'][$attach_id]['is_image'] ($get_attachments must be true)
Returns if the attachment is an image or not. If 0 is returned, it is false or empty. If 1 is returned, it is true.
$topic_data['first_post']['attachments'][$attach_id]['image']['id'] ($topic_data['first_post']['attachments'][$attach_id]['is_image'] must be 1)
Returns the ID of the image attached.
$topic_data['first_post']['attachments'][$attach_id]['image']['width'] ($topic_data['first_post']['attachments'][$attach_id]['is_image'] must be 1)
Returns the width of the attached image.
$topic_data['first_post']['attachments'][$attach_id]['image']['height'] ($topic_data['first_post']['attachments'][$attach_id]['is_image'] must be 1)
Returns the height of the attached image.
$topic_data['first_post']['attachments'][$attach_id]['image']['img'] ($topic_data['first_post']['attachments'][$attach_id]['is_image'] must be 1)
Displays the image only.
$topic_data['first_post']['attachments'][$attach_id]['image']['thumb'] ($topic_data['first_post']['attachments'][$attach_id]['is_image'] must be 1)
Displays a thumbnail of the image.
$topic_data['first_post']['attachments'][$attach_id]['image']['href'] ($topic_data['first_post']['attachments'][$attach_id]['is_image'] must be 1)
Returns the url only of the image.
$topic_data['first_post']['attachments'][$attach_id]['image']['link'] ($topic_data['first_post']['attachments'][$attach_id]['is_image'] must be 1)
Displays the link to the image, and embeds the image, making it clickable.
$topic_data['replies']
This array returns an array of what $topic_data['first_post'] would return.
$topic_data['more_replies_link'] (Only created when the total number of replies in a post exceeds $num_replies)
Returns the clickable link to the next reply in the topic.
tyty1234
Admin of tytyweb.net

Offline TamHaHaoJai

  • New User
  • *
  • Posts: 2
    • View Profile
  • SMF Version: BKK
Re: SSI Topics and Replies
« Reply #2 on: August 26, 2014, 05:52:47 PM »

Very useful What do you know?
I'm very curious at the right time.

Offline eec0

  • New User
  • *
  • Posts: 3
    • View Profile
  • SMF Version: 2.2
Re: SSI Topics and Replies
« Reply #3 on: September 29, 2014, 11:41:22 PM »
Practical Explanation ( For Example ) :- `1st of all can you tell me every single seconds detail from that time when you born ?? ( i need every seconds detail ?? that what- what you have thought and done on every single second )

can you tell me every single detail of your `1 cheapest Minute Or your whole hour, day, week, month, year or your whole life ??

if you are not able to tell me about this life then what proof do you have that you didn't forget your past ? and that you will not forget this present life in the future ?

that is Fact that Supreme Lord Krishna exists but we posses no such intelligence to understand him.
there is also next life. and i already proved you that no scientist, no politician, no so-called intelligent man in this world is able to understand this Truth. cuz they are imagining. and you cannot imagine what is god, who is god, what is after life etc.
_______
for example :Your father existed before your birth. you cannot say that before your birth your father don,t exists.

So you have to ask from mother, "Who is my father?" And if she says, "This gentleman is your father," then it is all right. It is easy.
Otherwise, if you makes research, "Who is my father?" go on searching for life; you'll never find your father.

( now maybe...maybe you will say that i will search my father from D.N.A, or i will prove it by photo's, or many other thing's which i will get from my mother and prove it that who is my Real father.{ So you have to believe the authority. who is that authority ? she is your mother. you cannot claim of any photo's, D.N.A or many other things without authority ( or ur mother ).

if you will show D.N.A, photo's, and many other proofs from other women then your mother. then what is use of those proofs ??} )

same you have to follow real authority. "Whatever You have spoken, I accept it," Then there is no difficulty. And You are accepted by Devala, Narada, Vyasa, and You are speaking Yourself, and later on, all the acaryas have accepted. Then I'll follow.
I'll have to follow great personalities. The same reason mother says, this gentleman is my father. That's all. Finish business. Where is the necessity of making research? All authorities accept Krsna, the Supreme Personality of Godhead. You accept it; then your searching after God is finished.

Why should you waste your time?
_______
all that is you need is to hear from authority ( same like mother ). and i heard this truth from authority " Srila Prabhupada " he is my spiritual master.
im not talking these all things from my own.
___________

in this world no `1 can be Peace full. this is all along Fact.

cuz we all are suffering in this world 4 Problems which are Disease, Old age, Death, and Birth after Birth.

tell me are you really happy ?? you can,t be happy if you will ignore these 4 main problem. then still you will be Forced by Nature.
___________________

if you really want to be happy then follow these 6 Things which are No illicit sex, No gambling, No drugs ( No tea & coffee ), No meat-eating ( No onion & garlic's )

5th thing is whatever you eat `1st offer it to Supreme Lord Krishna. ( if you know it what is Guru parama-para then offer them food not direct Supreme Lord Krishna )

and 6th " Main Thing " is you have to Chant " hare krishna hare krishna krishna krishna hare hare hare rama hare rama rama rama hare hare ".
_______________________________
If your not able to follow these 4 things no illicit sex, no gambling, no drugs, no meat-eating then don,t worry but chanting of this holy name ( Hare Krishna Maha-Mantra ) is very-very and very important.

Chant " hare krishna hare krishna krishna krishna hare hare hare rama hare rama rama rama hare hare " and be happy.

if you still don,t believe on me then chant any other name for 5 Min's and chant this holy name for 5 Min's and you will see effect. i promise you it works And chanting at least 16 rounds ( each round of 108 beads ) of the Hare Krishna maha-mantra daily.
____________
Here is no Question of Holy Books quotes, Personal Experiences, Faith or Belief. i accept that Sometimes Faith is also Blind. Here is already Practical explanation which already proved that every`1 else in this world is nothing more then Busy Foolish and totally idiot.
_________________________
Source(s):
every `1 is already Blind in this world and if you will follow another Blind then you both will fall in hole. so try to follow that person who have Spiritual Eyes who can Guide you on Actual Right Path. ( my Authority & Guide is my Spiritual Master " Srila Prabhupada " )
_____________
if you want to see Actual Purpose of human life then see this link : ( www.asitis.com {Bookmark it })
read it complete. ( i promise only readers of this book that they { he/she } will get every single answer which they want to know about why im in this material world, who im, what will happen after this life, what is best thing which will make Human Life Perfect, and what is perfection of Human Life. ) purpose of human life is not to live like animal cuz every`1 at present time doing 4 thing which are sleeping, eating, sex & fear. purpose of human life is to become freed from Birth after birth, Old Age, Disease, and Death.

Offline eec0

  • New User
  • *
  • Posts: 3
    • View Profile
  • SMF Version: 2.2
Re: SSI Topics and Replies
« Reply #4 on: November 29, 2014, 04:00:40 AM »
Practical Explanation ( For Example ) :- `1st of all can you tell me every single seconds detail from that time when you born ?? ( i need every seconds detail ?? that what- what you have thought and done on every single second )

can you tell me every single detail of your `1 cheapest Minute Or your whole hour, day, week, month, year or your whole life ??

if you are not able to tell me about this life then what proof do you have that you didn't forget your past ? and that you will not forget this present life in the future ?

that is Fact that Supreme Lord Krishna exists but we posses no such intelligence to understand him.
there is also next life. and i already proved you that no scientist, no politician, no so-called intelligent man in this world is able to understand this Truth. cuz they are imagining. and you cannot imagine what is god, who is god, what is after life etc.
_______
for example :Your father existed before your birth. you cannot say that before your birth your father don,t exists.

So you have to ask from mother, "Who is my father?" And if she says, "This gentleman is your father," then it is all right. It is easy.
Otherwise, if you makes research, "Who is my father?" go on searching for life; you'll never find your father.

( now maybe...maybe you will say that i will search my father from D.N.A, or i will prove it by photo's, or many other thing's which i will get from my mother and prove it that who is my Real father.{ So you have to believe the authority. who is that authority ? she is your mother. you cannot claim of any photo's, D.N.A or many other things without authority ( or ur mother ).

if you will show D.N.A, photo's, and many other proofs from other women then your mother. then what is use of those proofs ??} )

same you have to follow real authority. "Whatever You have spoken, I accept it," Then there is no difficulty. And You are accepted by Devala, Narada, Vyasa, and You are speaking Yourself, and later on, all the acaryas have accepted. Then I'll follow.
I'll have to follow great personalities. The same reason mother says, this gentleman is my father. That's all. Finish business. Where is the necessity of making research? All authorities accept Krsna, the Supreme Personality of Godhead. You accept it; then your searching after God is finished.

Why should you waste your time?
_______
all that is you need is to hear from authority ( same like mother ). and i heard this truth from authority " Srila Prabhupada " he is my spiritual master.
im not talking these all things from my own.
___________

in this world no `1 can be Peace full. this is all along Fact.

cuz we all are suffering in this world 4 Problems which are Disease, Old age, Death, and Birth after Birth.

tell me are you really happy ?? you can,t be happy if you will ignore these 4 main problem. then still you will be Forced by Nature.
___________________

if you really want to be happy then follow these 6 Things which are No illicit sex, No gambling, No drugs ( No tea & coffee ), No meat-eating ( No onion & garlic's )

5th thing is whatever you eat `1st offer it to Supreme Lord Krishna. ( if you know it what is Guru parama-para then offer them food not direct Supreme Lord Krishna )

and 6th " Main Thing " is you have to Chant " hare krishna hare krishna krishna krishna hare hare hare rama hare rama rama rama hare hare ".
_______________________________
If your not able to follow these 4 things no illicit sex, no gambling, no drugs, no meat-eating then don,t worry but chanting of this holy name ( Hare Krishna Maha-Mantra ) is very-very and very important.

Chant " hare krishna hare krishna krishna krishna hare hare hare rama hare rama rama rama hare hare " and be happy.

if you still don,t believe on me then chant any other name for 5 Min's and chant this holy name for 5 Min's and you will see effect. i promise you it works And chanting at least 16 rounds ( each round of 108 beads ) of the Hare Krishna maha-mantra daily.
____________
Here is no Question of Holy Books quotes, Personal Experiences, Faith or Belief. i accept that Sometimes Faith is also Blind. Here is already Practical explanation which already proved that every`1 else in this world is nothing more then Busy Foolish and totally idiot.
_________________________
Source(s):
every `1 is already Blind in this world and if you will follow another Blind then you both will fall in hole. so try to follow that person who have Spiritual Eyes who can Guide you on Actual Right Path. ( my Authority & Guide is my Spiritual Master " Srila Prabhupada " )
_____________
if you want to see Actual Purpose of human life then see this link : ( www.asitis.com {Bookmark it })
read it complete. ( i promise only readers of this book that they { he/she } will get every single answer which they want to know about why im in this material world, who im, what will happen after this life, what is best thing which will make Human Life Perfect, and what is perfection of Human Life. ) purpose of human life is not to live like animal cuz every`1 at present time doing 4 thing which are sleeping, eating, sex & fear. purpose of human life is to become freed from Birth after birth, Old Age, Disease, and Death.