Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Tomer on August 09, 2004, 05:30:03 PM

Title: [README] SSI FAQ's
Post by: Tomer on August 09, 2004, 05:30:03 PM
I've noticed that the SSI FAQ's may have gotten a bit lost in the boards, here are links. :D

Basic SSI FAQ (http://www.simplemachines.org/community/index.php?topic=12936.0)

Advanced SSI FAQ (http://www.simplemachines.org/community/index.php?topic=13016.0)

Expert SSI FAQ (http://www.simplemachines.org/community/index.php?topic=13205.0)

General Documentation on Using SSI (http://docs.simplemachines.org/index.php?topic=400.0)

Please remember, these are not official or anything.
Title: Re: [README] SSI FAQ's
Post by: Bandecko on September 01, 2004, 11:41:06 PM
These are all great!  I'd like to see more info on the $context variable and things of that nature.  I don't think I would have stumbled upon these until you condensed them here.  Thanks!
Title: Re: [README] SSI FAQ's
Post by: Tomer on September 02, 2004, 09:13:14 AM
Well that really isn't SSI but maybe. :)
Title: Re: [README] SSI FAQ's
Post by: Bandecko on September 02, 2004, 03:04:08 PM
Well, this doesn't seem like true ssi to me anyway, mainly just importing functions from the board to other aspects of a site using an included php file.  True ssi has a different markup and is content generated from the actual web server I thought.

That was my understanding of this this works anyway.  I could be way off base.

** edit **

Never mind.  I'm an idiot :P
I just read a little more about the $context variable.
Title: Re: [README] SSI FAQ's
Post by: [Unknown] on September 02, 2004, 08:44:27 PM
Well, this doesn't seem like true ssi to me anyway, mainly just importing functions from the board to other aspects of a site using an included php file.  True ssi has a different markup and is content generated from the actual web server I thought.

While that's right, it was only the initial (read: archaic :P) use of SSI.php.  It retains the same name, but it's now much much more useful as a PHP include.

-[Unknown]
Title: Re: [README] SSI FAQ's
Post by: Bandecko on September 02, 2004, 10:07:10 PM
Yeah, I was thinking the $context variable was a part of SSI.php, but I guess it's uses extend beyond that right?

Is there a list of the variables within the $context array, or am I stuck just looping through it on my own :)
Title: Re: [README] SSI FAQ's
Post by: [Unknown] on September 02, 2004, 10:35:50 PM
It differs from page to page - it is the *context* of that page view.  It is in its essence to vary in content.

I suggest you use print_r(), and remember that just because you see it's available in one place doesn't mean it's available everywhere - sometimes that wouldn't make sense.  For example, what would $context['member'] be on admin?

-[Unknown]
Title: Re: [README] SSI FAQ's
Post by: Bandecko on September 02, 2004, 11:50:07 PM
I remember reading that it did change on a per page basis (which makes sense given the name).

Thanks for the help.  The $context variable is something I havn't seen any where else, not just it's usage, but the idea behind it entirely.  It's a very sweet idea.

I plan on using it with access control to certain pages on the main site, so I'll be wanting to do some checking for admin or even member groups.  In order to do that though, I wanted to know exactly which array portions I should be using (the names mostly).  So I'll stop bugging you about it, and just do the work myself :)

Thanks a lot though!
Title: Re: [README] SSI FAQ's
Post by: bmupton on February 07, 2005, 08:49:23 PM
Is there a complete listing someplace with all the available parameters for all the ssi functions?

I've read the FAQ's, and they helped me tremendously, but I'd like a listing of all available parameters for each function.

Or can one glean this information by simply reading the ssi.php file?

Thanks,
-Brent
Title: Re: [README] SSI FAQ's
Post by: [Unknown] on February 07, 2005, 09:09:49 PM
Or can one glean this information by simply reading the ssi.php file?

Yes, this information is in that file.  When/if I ever have a spare moment again, I hope to write a bonified tutorial on SSI.php and a reference on the functions.

-[Unknown]
Title: Re: [README] SSI FAQ's
Post by: bmupton on February 08, 2005, 04:03:32 PM
Or can one glean this information by simply reading the ssi.php file?

Yes, this information is in that file. When/if I ever have a spare moment again, I hope to write a bonified tutorial on SSI.php and a reference on the functions.

-[Unknown]

This is very good news, expecially for those "less than versed" in php like me!  You're doing extremely great things here, and I think I can speak for everyone when I say, "Keep up the great work!"
Title: Re: [README] SSI FAQ's
Post by: mister on February 22, 2005, 10:51:19 AM
Is there any documentation that tells exactly what each function does and all the available options for those functions yet?

I think that would be very helpful when coding with SSI.
Title: Re: [README] SSI FAQ's
Post by: Oldiesmann on February 26, 2005, 10:00:36 PM
Open the file in a text or code editor and look at the comments... Very useful.
Title: Re: [README] SSI FAQ's
Post by: mister on February 28, 2005, 11:57:02 AM
I did that too, but i was wondering if there was more.
Title: Re: [README] SSI FAQ's
Post by: pivo on March 15, 2005, 05:56:34 AM
When I call the "recent-poll" function by using SSI, I don't get a view of the result of the poll.

Is there a way to show the results of the poll directly after voting on it? (it's the feedback that makes the poll attractive off course!  ;D)
Title: Re: [README] SSI FAQ's
Post by: Tanks on March 15, 2005, 12:26:16 PM
When I call the "recent-poll" function by using SSI, I don't get a view of the result of the poll.

Is there a way to show the results of the poll directly after voting on it? (it's the feedback that makes the poll attractive off course!  ;D)

i have been searching for an answer to this question to  :o

Anyone ?
Title: Re: [README] SSI FAQ's
Post by: nameless on April 08, 2005, 09:23:42 PM
ssi_showPoll(); might work for you. Inside the paranthesis enter the post # and the poll results will show.

I can't get ssi_recentPoll(); to show and give me the option to vote. anyone?
Title: Re: [README] SSI FAQ's
Post by: bloodmonkey on July 24, 2005, 04:04:25 PM
Hi everybody.... i like make something like this website: http://sentidourbano.com/news/julio05/50_070504.php (http://sentidourbano.com/news/julio05/50_070504.php)
look on bottom, the article's comments, they was linked to phpbb forums... how i can do that with my smf forums? any ssi fuctions to modify to make it....  ???

( sorry about my poor english  :( )
Title: Re: [README] SSI FAQ's
Post by: Neol on October 20, 2005, 05:30:30 AM
Is it possible to show in SSI.php the photos or attachments of a post?
Title: Re: [README] SSI FAQ's
Post by: Elmacik on October 21, 2005, 03:01:14 AM
i read all three of ssi faqs but couldnt find what i am looking for..
one friend is asking to make some of the detailed statistics appear in the board index.
of course its easy to do with SSI.
but he wants the statistics appear just like in statistics page. (with the blue percentage bars)
now, how can we do?
Title: Re: [README] SSI FAQ's
Post by: Gwydion Frost on December 18, 2005, 09:52:54 PM
Ok, maybe I'm just not following...and as smart as I like to think I am, it's a little frustrating to be sounding so stupid and not grasping what should be a simple concept.

Following the directions as I have read them in the Basic SSI FAQ:

Create a document with a php extension. Place code within it. Place UNNAMED php document SOMEWHERE RANDOM in your forum directory.

Errr...what do I name this document, and how the heck does the forum software know how to access it?

I have multiple forums.

I have a shared database for these forums, each install has it's own tables, with only a few tables shared, such as...
  shared_log_activity
  shared_log_floodcontrol
  shared_log_karma
  shared_log_online
  shared_log_subscribed
  shared_membergroups
  shared_members
  shared_personal_messages
  shared_pm_recipients
  shared_subscriptions

Now, the issue I have here, is that I am under the understanding that SSI will allow my folks to log in, and bop from board to board to board (I also have the cookies set the same for each board). How do I do so, with SSI, because right now, even with the shared tables and cookies, you still have to log in fresh for each board...and that just won't do!
Title: Re: [README] SSI FAQ's
Post by: Col on December 20, 2005, 10:21:52 AM
Ok, maybe I'm just not following...and as smart as I like to think I am, it's a little frustrating to be sounding so stupid and not grasping what should be a simple concept.

Following the directions as I have read them in the Basic SSI FAQ:

Create a document with a php extension. Place code within it. Place UNNAMED php document SOMEWHERE RANDOM in your forum directory.

Errr...what do I name this document, and how the heck does the forum software know how to access it?

It's just the way the tutorial is written. Tomer means, I think, that you just need to change the file extension (probably from HTML) to php. Tomer is assuming that you will be creating a new file, and I'm assuming that you just mean to modify one! - So, the name of the file will remain unchanged, just  the file extension to php.

You will need to add to the top of the file:

Code: [Select]
<?php
require("/home/simple/public_html/forum/SSI.php"); 
?>


..., but you may need to alter the server path. I am only just beginning to look at this myself, and I've read that the above code should go at the top of your file, but I've placed under my doctype decloration, and this seems to work.

You will then need to add the call in the body of your code where you want the php include to appear.
Title: Re: [README] SSI FAQ's
Post by: dvdd127 on January 18, 2006, 09:31:49 PM
thanks for the FAQ's
is it possible to SSI the whole header of the forum menu and all the stuff above it into my sites pages? i am only asking cause I would like to us the new default theme that came with 1.1 rc2 as my default and not have to use the old theme..

thanks in advance
Title: Re: [README] SSI FAQ's
Post by: Webrunner on January 21, 2006, 11:53:27 AM
Create a php file and start it with:

Code: [Select]
<?php
ob_start
();
$ssi_layers = array(&#39;main&#39;);
require_once(&#39;forum/SSI.php&#39;);
 
 
Title: Re: [README] SSI FAQ's
Post by: dvdd127 on January 21, 2006, 12:33:10 PM
Create a php file and start it with:

Code: [Select]
<?php
ob_start
();
$ssi_layers = array(&#39;main&#39;);
require_once(&#39;forum/SSI.php&#39;); 
Thanks much... my next question is how do I include the footer.
Title: Re: [README] SSI FAQ's
Post by: Webrunner on January 21, 2006, 01:58:16 PM
end the same page with:
Code: [Select]
ssi_shutdown();

?>
Title: Re: [README] SSI FAQ's
Post by: dvdd127 on January 21, 2006, 02:02:52 PM
end the same page with:
Code: [Select]
ssi_shutdown();

?>
thanks again.
Title: Re: [README] SSI FAQ's
Post by: omegasox on March 16, 2006, 05:11:08 PM
Hi. I tried the search button but it seems to be disabled at this time.

Is there any way to show the Avatar for the user posting using SSI instead of displaying just the username? I have the following code:

Code: [Select]
          <?php

ssi_boardNews
($board 1.0$limit 5$start null$length 250$output_method = &#39;echo&#39;);

?>

And it's all well and good, but it displays the username instead of the Avatar+Username. I would really like it to do both if possible.

Thanks for any help. :)
Title: Re: [README] SSI FAQ's
Post by: Jim R on May 07, 2006, 11:04:32 PM
SMF Version: SMF 1.0.5

I've been playing around with the SSI features recently but am not getting quite what I want.  I'm looking to just links the subject lines of the most recent topics from a specific board. 

I have the command that lists the most specific topics from a board, and I have manipulated the variables to just print certain portions of certain posts in a topic.


Code: [Select]
<?php

ssi_boardNews
($board null$limit null$start null$length null$output_method = &#39;echo&#39;);

?>

I also have the command that links the subject lines to the most recent topics from all my boards. 


Code: [Select]
<?php ssi_recentTopics(); ?>
I want to produce the links to the most recent topics from a specific forum.

Help?

Thanks.
Title: Re: [README] SSI FAQ's
Post by: B Patterson on May 15, 2006, 06:59:05 PM
Quote
but he wants the statistics appear just like in statistics page. (with the blue percentage bars)
now, how can we do?
Look at the smf_stats table and see what information you can extrapolate from it :)

Quote
Now, the issue I have here, is that I am under the understanding that SSI will allow my folks to log in, and bop from board to board to board (I also have the cookies set the same for each board). How do I do so, with SSI, because right now, even with the shared tables and cookies, you still have to log in fresh for each board...and that just won't do!
Are you using ssi_login() to create the form?  If not, try that.  It should log you in and direct you to the forum (unless you get redirected to the currently viewed page).  Here's an example:
www.roundcubeforum.net/portal/index.php

Quote
..., but you may need to alter the server path. I am only just beginning to look at this myself, and I've read that the above code should go at the top of your file, but I've placed under my doctype decloration, and this seems to work.
This prevents sessions from being used on your page.  So if you have any information for user-login and such, you won't be able to retreive it :(  You should include before any html output to the browser just so that you can have access to the sessions :)

Quote
Is there any way to show the Avatar for the user posting using SSI instead of displaying just the username?
It should be stored in: $context['user']['avatar']['href'] or $context['user']['avatar']['img'] :)

Quote
I want to produce the links to the most recent topics from a specific forum.
NOTE: The following is based off of 1.1RC2, not 1.0.5.  Sorry :(
Tough to do... especially if you have lots of boards.  So I'll take some time with this one.
-- First: Find out the ID of the board you want to view (look at the link, it should be something like index.php?board=X.X).  For the rest of the boards, we're going to exclude them.  So make sure you know the highest board ID (use the admin panel if you want, or look at the mySQL table)

Now, just call your function like so:
Code: [Select]
<?php
$exclude 
= array(&#39;1&#39;,&#39;2&#39;,&#39;3&#39;,&#39;4&#39;,&#39;5&#39;,&#39;7&#39;,&#39;8&#39;,&#39;9&#39;,&#39;10&#39;);
$topics ssi_recentTopics(10$exclude, &#39;array&#39;);
So what this does is we exclude all boards except for board ID 6.  It also pulls the 10 most recent topics.  And finally, it returns the information in an array, rather than just displaying it.
So how you deal with it when it's returned is up to you.  I would guess you'd want something like:
Code: [Select]
<?php
$exclude 
= array(&#39;1&#39;,&#39;2&#39;,&#39;3&#39;,&#39;4&#39;,&#39;5&#39;,&#39;7&#39;,&#39;8&#39;,&#39;9&#39;,&#39;10&#39;);
$topics ssi_recentTopics(10$exclude, &#39;array&#39;);

foreach($topics as $topic)
  echo 
$topic[&#39;link&#39;], &#39;<br />&#39;;
?>
That will output a link on each line with just the subject.  It will show all 10 recent topics.

Now, something I'd like to see added, is the "View unread replies to subscribed topics" function.  I'm lookin to get it working now, but don't know what to query, since I don't know how subscriptions are handled.  Perhaps [Unknown] can help?
Title: Re: [README] SSI FAQ's
Post by: airjer on July 05, 2006, 11:10:41 PM
Quote
but he wants the statistics appear just like in statistics page. (with the blue percentage bars)
now, how can we do?
Look at the smf_stats table and see what information you can extrapolate from it :)

Quote
Now, the issue I have here, is that I am under the understanding that SSI will allow my folks to log in, and bop from board to board to board (I also have the cookies set the same for each board). How do I do so, with SSI, because right now, even with the shared tables and cookies, you still have to log in fresh for each board...and that just won't do!
Are you using ssi_login() to create the form?  If not, try that.  It should log you in and direct you to the forum (unless you get redirected to the currently viewed page).  Here's an example:
www.roundcubeforum.net/portal/index.php

Quote
..., but you may need to alter the server path. I am only just beginning to look at this myself, and I've read that the above code should go at the top of your file, but I've placed under my doctype decloration, and this seems to work.
This prevents sessions from being used on your page.  So if you have any information for user-login and such, you won't be able to retreive it :(  You should include before any html output to the browser just so that you can have access to the sessions :)

Quote
Is there any way to show the Avatar for the user posting using SSI instead of displaying just the username?
It should be stored in: $context['user']['avatar']['href'] or $context['user']['avatar']['img'] :)

Quote
I want to produce the links to the most recent topics from a specific forum.
NOTE: The following is based off of 1.1RC2, not 1.0.5.  Sorry :(
Tough to do... especially if you have lots of boards.  So I'll take some time with this one.
-- First: Find out the ID of the board you want to view (look at the link, it should be something like index.php?board=X.X).  For the rest of the boards, we're going to exclude them.  So make sure you know the highest board ID (use the admin panel if you want, or look at the mySQL table)

Now, just call your function like so:
Code: [Select]
<?php
$exclude 
= array('1','2','3','4','5','7','8','9','10');
$topics ssi_recentTopics(10$exclude'array');
So what this does is we exclude all boards except for board ID 6.  It also pulls the 10 most recent topics.  And finally, it returns the information in an array, rather than just displaying it.
So how you deal with it when it's returned is up to you.  I would guess you'd want something like:
Code: [Select]
<?php
$exclude 
= array('1','2','3','4','5','7','8','9','10');
$topics ssi_recentTopics(10$exclude'array');

foreach(
$topics as $topic)
  echo $topic['link'], '<br />';
?>
That will output a link on each line with just the subject.  It will show all 10 recent topics.

Now, something I'd like to see added, is the "View unread replies to subscribed topics" function.  I'm lookin to get it working now, but don't know what to query, since I don't know how subscriptions are handled.  Perhaps [Unknown] can help?

Is it possible to display the latest topics based on when they are first posted? Once a reply has been sent through a topic will jump to the top of the list! I do not want that to happen. Also... I tried using the same code with ssi_topTopicsViews... but excluding certain forums is not working!
Title: Re: [README] SSI FAQ's
Post by: B Patterson on July 08, 2006, 02:10:54 PM
Yes it is possible.  You'd have to create your own query to look at the topics board and extrapolate the information from the timestamp of the post.  Replies are held in the posts table, but if you look at only information in the topics table, you will get when the topic was created ;)

An example query that would return the topic title and time created would be:

Code: [Select]
SELECT t.ID_TOPIC, t.ID_BOARD, t.isSticky, t.locked,
m.subject, m.posterName, m.posterTime
FROM smf_topics AS t
INNER JOIN smf_messages AS m
  ON t.ID_FIRST_MSG = m.ID_MSG
ORDER BY m.posterTime ASC
LIMIT 0, 10

That will get the last 10 created topics, whether there have been replies or not. 
Title: Re: [README] SSI FAQ's
Post by: airjer on July 08, 2006, 03:49:19 PM
Yes it is possible.  You'd have to create your own query to look at the topics board and extrapolate the information from the timestamp of the post.  Replies are held in the posts table, but if you look at only information in the topics table, you will get when the topic was created ;)

An example query that would return the topic title and time created would be:

Code: [Select]
SELECT t.ID_TOPIC, t.ID_BOARD, t.isSticky, t.locked,
m.subject, m.posterName, m.posterTime
FROM smf_topics AS t
INNER JOIN smf_messages AS m
  ON t.ID_FIRST_MSG = m.ID_MSG
ORDER BY m.posterTime ASC
LIMIT 0, 10

That will get the last 10 created topics, whether there have been replies or not. 

And how would I use this  ???

lol
Title: Re: [README] SSI FAQ's
Post by: B Patterson on July 08, 2006, 04:21:34 PM
As you normally would with any other query in PHP.... mysql_query()... mysql_fetch_array()....
Title: Re: [README] SSI FAQ's
Post by: mark7144 on August 25, 2006, 07:22:28 PM
As you normally would with any other query in PHP.... mysql_query()... mysql_fetch_array()....

Still not following...

I want the same but was hoping you can just add something to the recent_topics SSI code that was posted earlier on in this thread.
Title: Re: [README] SSI FAQ's
Post by: airjer on August 25, 2006, 07:28:03 PM
As you normally would with any other query in PHP.... mysql_query()... mysql_fetch_array()....

Still not following...

I want the same but was hoping you can just add something to the recent_topics SSI code that was posted earlier on in this thread.

Yea I didn't understand it either... lol
Title: Re: [README] SSI FAQ's
Post by: mark7144 on August 25, 2006, 07:45:19 PM
As you normally would with any other query in PHP.... mysql_query()... mysql_fetch_array()....

Still not following...

I want the same but was hoping you can just add something to the recent_topics SSI code that was posted earlier on in this thread.

Yea I didn't understand it either... lol

There is a better way then his or maybe the same thing but explained clearly with all the code.

Put this at the bottom of your SSI.php before the ?>:

Code: [Select]
// Recent topic list:   [board] Subject by Poster Date
function ssi_recentTopicsStarted($num_recent = 8, $exclude_boards = null, $output_method = 'echo')
{
global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings;

if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
$exclude_boards = array($modSettings['recycle_board']);
else
$exclude_boards = empty($exclude_boards) ? array() : $exclude_boards;

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = db_query("
SELECT
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
WHERE t.ID_FIRST_MSG >= " . ($modSettings['maxMsgID'] - 350 * min($num_recent, 5)) . "
AND t.ID_FIRST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($exclude_boards) ? '' : "
AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_FIRST_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '')));
if (strlen($row['body']) > 128)
$row['body'] = substr($row['body'], 0, 128) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => $row['ID_TOPIC'],
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
);
}
mysql_free_result($request);

// Just return it.
if ($output_method != 'echo' || empty($posts))
return $posts;

echo '
<table border="0" class="ssi_table">';
foreach ($posts as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">
[', $post['board']['link'], ']
</td>
<td valign="top">',$post['link'], '
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '
</td>
<td align="right" nowrap="nowrap">
', $post['time'], '
</td>
</tr>';
echo '
</table>';
}

?>

And you can now just use 'ssi_recentTopicsStarted' as an SSI function.
Title: Re: [README] SSI FAQ's
Post by: B Patterson on August 25, 2006, 10:12:19 PM
Give a man a fish, feed him for a day.
Teach a man to fish, feed him for life.


Giving the query fulfilled the first part.
Telling them to use mysql_query() or mysql_fetch_array() they could have googled for it, found out that it's a PHP function, read the manual and tried something.  But who am I to at least think people would try something before asking for an answer.
Title: Re: [README] SSI FAQ's
Post by: mark7144 on August 26, 2006, 04:07:44 AM
Give a man a fish, feed him for a day.
Teach a man to fish, feed him for life.


Giving the query fulfilled the first part.
Telling them to use mysql_query() or mysql_fetch_array() they could have googled for it, found out that it's a PHP function, read the manual and tried something.  But who am I to at least think people would try something before asking for an answer.

Erm I think you expect too much of what may be just an ordinary SMF user. Get off your high horse and realise that some of us here don't have that much knowledge in php or sql.

Thankfully I was here to give an answer with clear simple instructions and with the full needed code.
Title: Re: [README] SSI FAQ's
Post by: B Patterson on August 26, 2006, 06:46:04 AM
Quote
Erm I think you expect too much of what may be just an ordinary SMF user. Get off your high horse and realise that some of us here don't have that much knowledge in php or sql.

Thankfully I was here to give an answer with clear simple instructions and with the full needed code.
1.) I'm not on a high horse.
2.) The answer was given, though shrouded in a mask of questions as to how to use it, it was given.
3.) Whatever... I'm done.  I've answered plenty of other questions successfully.  And with the user saying nothing to the extent of their PHP or SQL knowledge (if they are even the original poster) but knowing enough to want a new query to get certain info, then yes, I should just be able to give them a query to work from.
Title: Re: [README] SSI FAQ's
Post by: mark7144 on September 17, 2006, 05:30:08 PM
Anyone know if it's possible to have the 'Send Topic' using SSI?
Title: Re: [README] SSI FAQ's
Post by: Oldiesmann on September 30, 2006, 08:06:07 PM
Not directly, but ssi_recentPosts, ssi_recentTopics, ssi_boardNews and ssi_topTopics all return the topic ID as part of the array of info if you choose that output method, so you'd just need to output the link based on that - the URL is index.php?action=sendtopic;topic={topic_id}.
Title: Re: [README] SSI FAQ's
Post by: addictedBG on November 02, 2006, 04:17:20 PM
ow could I understand all the command ...I mean such as $news['icon'], '', $news['subject'], '<span class="smaller">', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], '', $news['link'], ' | ', $news['new_comment'], '
Title: Re: [README] SSI FAQ's
Post by: fwitt on November 11, 2006, 04:49:02 PM
normally from the context, as $news appears lots I assume its something to do with displaying news posts,
$news['icon'] probly holds the info for displaying the icon for the news article
$news['subject'] could this be the variable containing the subject of the news article
'<span class="smaller">' html i assume class="smaller" means that it belong to a css class that shrinks the text size
$news['time'] probly the time the news article was posted
$txt[525] a text string what it is replaced with will be found in the relevant language file so if the code is in news.template.php the $txt variable will probly be in news.yourlanguage.php
$news['poster']['link'] probly a link to the profile of the poster of the news article
$news['link'] a link to the news article itself
$news['new_comment'] could it be a link to the comments about the news article?

as I said look at the context of the code the variables are in and what there names are
if your not sure whats in a variable a simple
Code: [Select]
echo '$variable = ' .  $variable; will show you what the variable contains in a given situation which should give you a clue as to what it does.
Title: Re: [README] SSI FAQ's
Post by: Daerchwing on November 28, 2006, 06:23:21 AM
I'm having a problem using SSI on my site.

I've included the file as per instructions, but when I try to use a SSI function such as ssi_recentTopics(); I get the following error:
Code: [Select]
Fatal error: Call to undefined function db_query() in /pathinfo removed by me/public_html/test/forums/SSI.php on line 244
What do I do to correct this?

I'm running 1.1 RC3 and I include SSI.php from my WordPress header.

Edit: sorry if this isn't the right place to ask this sort of question.

Edit 2: NM, I figured it out.
Title: Re: [README] SSI FAQ's
Post by: brianjw on March 22, 2007, 04:27:18 PM
Tomer,
Since you wrote these, I am hoping you will be able to help me with something. But it's a bit long so its in its own topic.

http://www.simplemachines.org/community/index.php?topic=159588.0

Thanks,
Brianjw

PS: im a bit late posting lol :P
Title: Re: [README] SSI FAQ's
Post by: 321Hosted.com on October 24, 2007, 02:53:35 AM
I am a bit lost here, SSI is not my thing by far! I read the basic FAQ and am still lost!

I have a free web hosting business that offers free forum and cpanel hosting. I use SMF for the forum. The forum is also where users signup for their free account (I have added the custom profile fields mod to collect the needed info).

What I want this to do is display on one page, the members that are using free cpanel hosting, and the members that are using free forum hosting. I have these member groups setup, but I have no idea how to get a page setup so I can view the 2 member groups and the people in them.

Any help would be greatly appreciated!
Title: Re: [README] SSI FAQ's
Post by: B Patterson on October 24, 2007, 10:01:26 AM
Well, without having a function called "getMembersByGroup", there's not a whole lot to make this easy.  You could use this though:

function getMembersByGroup($groupname, $max=10, $output_method='string')
{
    global $db_prefix;

    $request = db_query("SELECT mem.memberName, mem.posts
                                  FROM {$db_prefix}members AS mem
                                  LEFT JOIN {$db_prefix}membergroups AS grp
                                       ON grp.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP)
                                  ORDER BY mem.memberName ASC
                                  LIMIT 0,{$max}", __FILE__, __LINE__);

    $member = array();

    while($row = mysql_fetch_assoc($result))
    {
        $member[] = array('name'=>$row['memberName'],
                                  'posts'=>$row['posts']);
    }

    if($output_method != 'string')
        return $return;

    $string = '<table>';
    foreach($member as $mem)
    {
        $string .= '<tr><td>', $mem['name'], '</td><td>', $mem['posts'], '</td></tr>';
    }
    $string .= '</table>';

    return $string;
}

include_once('SSI.php');
print_r(getmembersByGroup('FreeForum', 10, 'array'));
echo getMembersByGroup('FreeCpanel', 5);

Not guaranteed to work, but something like that would be what you want....
Title: Re: [README] SSI FAQ's
Post by: vsobral on November 08, 2007, 01:37:49 PM
How can I use ssi functions with mouse events?

An example of what i was trying to do with no success

Code: [Select]
<td class="windowbg" width="20%" align="left"> <input type="button"  value="Administradores" onclick=';
echo"'";

echo '
document.getElementById("ct").innerHTML = "'ssi_function()'"';

echo "'";
echo '
 />...


This works with variables but not with ssi functions

Thanks
Title: Re: [README] SSI FAQ's
Post by: fwitt on November 08, 2007, 03:21:06 PM
quick thing that looks wrong to me is this

Code: [Select]
echo '
document.getElementById("ct").innerHTML = "'ssi_function()'"';

shouldnt it be

Code: [Select]
echo '
document.getElementById("ct").innerHTML = "' , ssi_function() , '"';
Title: Re: [README] SSI FAQ's
Post by: vsobral on November 09, 2007, 08:12:48 AM
I've forgot to put the comas, but that is'nt the problem.

 here is the full code


Code: [Select]
<?php





if (!defined('SMF'))
die('Hacking attempt...');

// Don't do anything if SMF is already loaded.


require(dirname(__FILE__) . '/../SSI.php');

function 
template_main()
{
global 
$context$settings$options$txt$scripturl;

echo 
'


<table width="100%" border="0" cellspacing="0" cellpadding="3" >
<tr>
<td>'
theme_linktree(), '</td>
</tr>
</table>

<table width="100%" border="0" cellspacing="0" cellpadding="4" align="center" class="tborder">
<tr class="titlebg" >
<td align="center" width="100%">Staff do P@P</td>
</tr></table>
<table width="20%" border="0" cellspacing="0" cellpadding="4" align="left" class="tborder">

<tr>




<td class="windowbg" width="20%" align="left"> <input type="button"  value="Administradores" onclick='
;
echo
"'";

echo 
'
document.getElementById("ct").innerHTML = "' 
ssi_recentTopics()  , '"';

echo 
"'";
echo 
'
 /> <br />
  </td>  </tr></table>
  
  
  <table width="40%" border="0" cellspacing="0" cellpadding="4" align="center">
  
  <tr> 
  '
;
 


echo 
'
</tr>
</table>

<div id="ct">oláaaaaaaaaaaa</div>
'
;




Thanks for the help


Title: Re: [README] SSI FAQ's
Post by: vsobral on November 14, 2007, 01:29:58 PM
somebody please?
Title: Re: [README] SSI FAQ's
Post by: otectom on January 04, 2008, 10:08:00 PM
is it possible to use SSI to add calendar events to another page of your site?
Title: Re: [README] SSI FAQ's
Post by: fwitt on January 05, 2008, 12:54:44 PM
ssi_todaysEvents and ssi_todaysCalender both display Calender events.

I personally have a page on my website that lists the next years Calender events in order of start date using ssi.
Title: Re: [README] SSI FAQ's
Post by: otectom on January 05, 2008, 01:08:30 PM
Thank you!
Title: Re: [README] SSI FAQ's
Post by: otectom on January 06, 2008, 06:32:28 PM
Ok, ive seen the examples for today's events and recent evente, but what about upcoming events like everything for the next month/months maybe similar to how events show up on the bottom of the forum
Title: Re: [README] SSI FAQ's
Post by: fwitt on January 07, 2008, 08:13:55 AM
I have a customSSI.php which has modified versions of some of the SSI.php functions that fit my needs.
you need to require_once both this file and SSI.php in the file you wish to use it.

To show the calender events the user can see this function is called by the line.

Code: [Select]
ssi_ListEvents($max_events = 100, $output_method = 'echo', $dateFrom = date("Y-m-d"), $dateTo = (date("Y")+1) . '-' . date("m") . '-' .  date("d"));

Which output the first 100 calender events for the next year that the user can see.

following is the code of the function itself

Code: [Select]
// Show events between $dateFrom and $dateTo.
function ssi_ListEvents($max_events = 7, $output_method = 'echo', $dateFrom = '0001-01-01', $dateTo = '0001-01-01')
{
global $db_prefix, $user_info, $scripturl, $modSettings, $txt, $sc, $ID_MEMBER;

// Find all events which are happening in the near future that the member can see.
$request = db_query("
SELECT
cal.ID_EVENT, cal.startDate, cal.endDate, cal.title, cal.ID_MEMBER, cal.ID_TOPIC,
cal.ID_BOARD, t.ID_FIRST_MSG
FROM {$db_prefix}calendar AS cal
LEFT JOIN {$db_prefix}boards AS b ON (b.ID_BOARD = cal.ID_BOARD)
LEFT JOIN {$db_prefix}topics AS t ON (t.ID_TOPIC = cal.ID_TOPIC)
WHERE cal.startDate <= '" . $dateTo . "'
AND cal.startDate >= '" . $dateFrom . "'
AND (cal.ID_BOARD = 0 OR $user_info[query_see_board])
ORDER BY cal.startDate ASC
LIMIT $max_events", __FILE__, __LINE__);
$return = array();
$duplicates = array();
while ($row = mysql_fetch_assoc($request))
{
// Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have.
/*if (!empty($duplicates[$row['title'] . $row['ID_TOPIC']]))
continue; */

// Censor the title.
censorText($row['title']);

/*if ($row['startDate'] < strftime('%Y-%m-%d', forum_time(false)))
$date = strftime('%Y-%m-%d', forum_time(false));
else*/
$date = $row['startDate'];

$return[$date][] = array(
'id' => $row['ID_EVENT'],
'title' => $row['title'],
'can_edit' => allowedTo('calendar_edit_any') || ($row['ID_MEMBER'] == $ID_MEMBER && allowedTo('calendar_edit_own')),
'modify_href' => $scripturl . '?action=' . ($row['ID_BOARD'] == 0 ? 'calendar;sa=post;' : 'post;msg=' . $row['ID_FIRST_MSG'] . ';topic=' . $row['ID_TOPIC'] . '.0;calendar;') . 'eventid=' . $row['ID_EVENT'] . ';sesc=' . $sc,
'href' => $row['ID_BOARD'] == 0 ? '' : $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0',
'link' => $row['ID_BOARD'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['title'] . '</a>',
'start_date' => $row['startDate'],
'end_date' => $row['endDate'],
'is_last' => false
);

// Let's not show this one again, huh?
$duplicates[$row['title'] . $row['ID_TOPIC']] = true;
}
mysql_free_result($request);

foreach ($return as $mday => $array)
$return[$mday][count($array) - 1]['is_last'] = true;

if ($output_method != 'echo' || empty($return))
return $return;

// Well the output method is echo.
$tempyear = 0001;
        $tempmonth = 'bob';
foreach ($return as $mday => $array)
foreach ($array as $event)
{
if (strftime("%Y",strtotime($event['start_date'])) != $tempyear)
{
                          $tempyear = strftime("%Y",strtotime($event['start_date']));
                          echo '<h3>' . $tempyear . '</h3>';
                        }
                        if (strftime("%B",strtotime($event['start_date'])) != $tempmonth)
{
                          $tempmonth = strftime("%B",strtotime($event['start_date']));
                          echo '<h3>' . $tempmonth . '</h3>';
                        }
                        if ($event['can_edit'])
echo '
<a href="' . $event['modify_href'] . '" style="color: #FF0000;">*</a> ';

echo '
' . date("jS",strtotime($event['start_date']));
                        if ($event['start_date'] != $event['end_date'])
                          echo '-' . date("jS",strtotime($event['end_date']));
                        echo ' ' . $event['link'] . '<br/>';
}
}
Title: Re: [README] SSI FAQ's
Post by: otectom on January 07, 2008, 08:15:23 PM
fwitt, thank you, this is exactly what I am looking for to add to my site, I understand how to place the function on the page where I want to display the events, however I am unsure what to do with the other hunk of code there.  Does that need to be added to my ssi.php file?  if so where?
Title: Re: [README] SSI FAQ's
Post by: fwitt on January 08, 2008, 08:05:22 AM
dont add it to your SSI.php (it would work but you would have to do it every time you updated SMF) put it into a new file called CustomSSI.php and include this to your file in the same way as you would SSI.php.

so copy and paste this code to a file called CustomSSI.php and upload it to your forums root.

Code: [Select]
<?php
require_once("SSI.php");

// Show events between $dateFrom and $dateTo.
function ssi_ListEvents($max_events 7$output_method 'echo'$dateFrom '0001-01-01'$dateTo '0001-01-01')
{
global $db_prefix$user_info$scripturl$modSettings$txt$sc$ID_MEMBER;

// Find all events which are happening in the near future that the member can see.
$request db_query("
SELECT
cal.ID_EVENT, cal.startDate, cal.endDate, cal.title, cal.ID_MEMBER, cal.ID_TOPIC,
cal.ID_BOARD, t.ID_FIRST_MSG
FROM 
{$db_prefix}calendar AS cal
LEFT JOIN 
{$db_prefix}boards AS b ON (b.ID_BOARD = cal.ID_BOARD)
LEFT JOIN 
{$db_prefix}topics AS t ON (t.ID_TOPIC = cal.ID_TOPIC)
WHERE cal.startDate <= '" 
$dateTo "'
AND cal.startDate >= '" 
$dateFrom "'
AND (cal.ID_BOARD = 0 OR 
$user_info[query_see_board])
ORDER BY cal.startDate ASC
LIMIT 
$max_events"__FILE____LINE__);
$return = array();
$duplicates = array();
while ($row mysql_fetch_assoc($request))
{
// Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have.
/*if (!empty($duplicates[$row['title'] . $row['ID_TOPIC']]))
continue; */

// Censor the title.
censorText($row['title']);

/*if ($row['startDate'] < strftime('%Y-%m-%d', forum_time(false)))
$date = strftime('%Y-%m-%d', forum_time(false));
else*/
$date $row['startDate'];

$return[$date][] = array(
'id' => $row['ID_EVENT'],
'title' => $row['title'],
'can_edit' => allowedTo('calendar_edit_any') || ($row['ID_MEMBER'] == $ID_MEMBER && allowedTo('calendar_edit_own')),
'modify_href' => $scripturl '?action=' . ($row['ID_BOARD'] == 'calendar;sa=post;' 'post;msg=' $row['ID_FIRST_MSG'] . ';topic=' $row['ID_TOPIC'] . '.0;calendar;') . 'eventid=' $row['ID_EVENT'] . ';sesc=' $sc,
'href' => $row['ID_BOARD'] == '' $scripturl '?topic=' $row['ID_TOPIC'] . '.0',
'link' => $row['ID_BOARD'] == $row['title'] : '<a href="' $scripturl '?topic=' $row['ID_TOPIC'] . '.0">' $row['title'] . '</a>',
'start_date' => $row['startDate'],
'end_date' => $row['endDate'],
'is_last' => false
);

// Let's not show this one again, huh?
$duplicates[$row['title'] . $row['ID_TOPIC']] = true;
}
mysql_free_result($request);

foreach ($return as $mday => $array)
$return[$mday][count($array) - 1]['is_last'] = true;

if ($output_method != 'echo' || empty($return))
return $return;

// Well the output method is echo.
$tempyear 0001;
        
$tempmonth 'bob';
foreach ($return as $mday => $array)
foreach ($array as $event)
{
if (strftime("%Y",strtotime($event['start_date'])) != $tempyear)
{
                          
$tempyear strftime("%Y",strtotime($event['start_date']));
                          echo 
'<h3>' $tempyear '</h3>';
                        }
                        if (
strftime("%B",strtotime($event['start_date'])) != $tempmonth)
{
                          
$tempmonth strftime("%B",strtotime($event['start_date']));
                          echo 
'<h3>' $tempmonth '</h3>';
                        }
                        if (
$event['can_edit'])
echo '
<a href="' 
$event['modify_href'] . '" style="color: #FF0000;">*</a> ';

echo '
date("jS",strtotime($event['start_date']));
                        if (
$event['start_date'] != $event['end_date'])
                          echo 
'-' date("jS",strtotime($event['end_date']));
                        echo 
' ' $event['link'] . '<br/>';
}
}
?>


Then at the top of the php file you want to call it from add the line

Code: [Select]
require_once("smf/CustomSSI.php");

directly underneath the <?php

then when you wish the info to appear call the function

Code: [Select]
ssi_ListEvents($max_events = 100, $output_method = 'echo', $dateFrom = date("Y-m-d"), $dateTo = (date("Y")+1) . '-' . date("m") . '-' .  date("d"));
Title: Re: [README] SSI FAQ's
Post by: otectom on January 08, 2008, 07:29:59 PM
fwitt, thank you very much.  I followed your instructions and it worked perfectly.  I also slightly modified your code to look the way I wanted to.  I've been wanting to learn php coding for some time now, and this is honestly the first thing i've tried. 
Title: Re: [README] SSI FAQ's
Post by: wunderwood on September 01, 2009, 10:11:22 PM
These should absolutely be a sticky or placed prominently in the SMF API documentation. THANKS for posting them!

I've noticed that the SSI FAQ's may have gotten a bit lost in the boards, here are links. :D

Basic SSI FAQ (http://www.simplemachines.org/community/index.php?topic=12936.0)

Advanced SSI FAQ (http://www.simplemachines.org/community/index.php?topic=13016.0)

Expert SSI FAQ (http://www.simplemachines.org/community/index.php?topic=13205.0)

General Documentation on Using SSI (http://docs.simplemachines.org/index.php?topic=400.0)

Please remember, these are not official or anything.
Title: Re: [README] SSI FAQ's
Post by: Arantor on September 01, 2009, 10:15:14 PM
See the Important Customization sticky topic in this board, it links to this very topic!
Title: Re: [README] SSI FAQ's
Post by: wunderwood on September 01, 2009, 10:21:53 PM
<face palms> sorry. feel free to remove this and the other post then! I need to read more carefully.
Title: Re: [README] SSI FAQ's
Post by: Arantor on September 01, 2009, 10:23:57 PM
No, it's a perfectly valid question, because it isn't immediately clear.
Title: Re: [README] SSI FAQ's
Post by: Foxylucious on December 21, 2009, 09:16:54 AM
I like to thank Tomer for writing these SSI FAQ's,
And i like to Thank The SMF Team for making this Great Forum and Community Software.

The possibility's are endless with this Software, and i like it how i can now make a nice community around my website with SMF as the basis :P

Sorry if i go a little off-topic here, just speaking my mind.

Greatings Foxman :P