News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

[README] SSI FAQ's

Started by Tomer, August 09, 2004, 05:30:03 PM

Previous topic - Next topic

Gwydion Frost

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!

Col

Quote from: GwydionFrost 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?

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:

<?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.

dvdd127

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

Webrunner

Create a php file and start it with:


<?php
ob_start
();
$ssi_layers = array('main');
require_once(
'forum/SSI.php');
 
 
There is a difference between knowing the path and walking the path.

=========================================
Vrouwen Power! | Sprintweb: No nonsense e-Business consultancy

dvdd127

Quote from: Webrunner on January 21, 2006, 11:53:27 AM
Create a php file and start it with:


<?php
ob_start
();
$ssi_layers = array('main');
require_once(
'forum/SSI.php'); 

Thanks much... my next question is how do I include the footer.

Webrunner

end the same page with:
ssi_shutdown();

?>
There is a difference between knowing the path and walking the path.

=========================================
Vrouwen Power! | Sprintweb: No nonsense e-Business consultancy

dvdd127


omegasox

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:

          <?php

ssi_boardNews
($board 1.0$limit 5$start null$length 250$output_method 'echo');

?>


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. :)

Jim R

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.



<?php

ssi_boardNews
($board null$limit null$start null$length null$output_method 'echo');

?>


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



<?php ssi_recentTopics(); ?>


I want to produce the links to the most recent topics from a specific forum.

Help?

Thanks.

B Patterson

#29
Quotebut 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 :)

QuoteNow, 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 :)

QuoteIs 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'] :)

QuoteI 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:
<?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:
<?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?

airjer

Quote from: bpat1434 on May 15, 2006, 06:59:05 PM
Quotebut 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 :)

QuoteNow, 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 :)

QuoteIs 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'] :)

QuoteI 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:
<?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:
<?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!

B Patterson

#31
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:

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. 

airjer

Quote from: bpat1434 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:

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

B Patterson

As you normally would with any other query in PHP.... mysql_query()... mysql_fetch_array()....

mark7144

Quote from: bpat1434 on July 08, 2006, 04:21:34 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.

airjer

Quote from: mark7144 on August 25, 2006, 07:22:28 PM
Quote from: bpat1434 on July 08, 2006, 04:21:34 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

mark7144

Quote from: airjer on August 25, 2006, 07:28:03 PM
Quote from: mark7144 on August 25, 2006, 07:22:28 PM
Quote from: bpat1434 on July 08, 2006, 04:21:34 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 ?>:


// 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.

B Patterson

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.

mark7144

Quote from: bpat1434 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.

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.

B Patterson

QuoteErm 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.

Advertisement: