Advertisement:

Author Topic: [README] SSI FAQ's  (Read 165393 times)

Offline mark7144

  • Sophist Member
  • *****
  • Posts: 1,174
Re: [README] SSI FAQ's
« Reply #40 on: September 17, 2006, 05:30:08 PM »
Anyone know if it's possible to have the 'Send Topic' using SSI?

Offline Oldiesmann

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,868
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • https://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: [README] SSI FAQ's
« Reply #41 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}.
Michael Eshom
Cincy Space - now open!

Offline addictedBG

  • Semi-Newbie
  • *
  • Posts: 11
Re: [README] SSI FAQ's
« Reply #42 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'], '

Offline fwitt

  • Full Member
  • ***
  • Posts: 479
  • Gender: Male
Re: [README] SSI FAQ's
« Reply #43 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.

Daerchwing

  • Guest
Re: [README] SSI FAQ's
« Reply #44 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.
« Last Edit: March 22, 2007, 04:30:03 PM by Daerchwing »

Offline brianjw

  • SMF Hero
  • ******
  • Posts: 2,157
  • Gender: Male
Re: [README] SSI FAQ's
« Reply #45 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

Offline 321Hosted.com

  • Newbie
  • *
  • Posts: 9
Re: [README] SSI FAQ's
« Reply #46 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!

Offline B Patterson

  • Full Member
  • ***
  • Posts: 512
  • Gender: Male
  • Never Miss an Opportunity to be Great
Re: [README] SSI FAQ's
« Reply #47 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....
« Last Edit: October 24, 2007, 10:04:22 AM by bpat1434 »

Offline vsobral

  • Semi-Newbie
  • *
  • Posts: 10
Re: [README] SSI FAQ's
« Reply #48 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

Offline fwitt

  • Full Member
  • ***
  • Posts: 479
  • Gender: Male
Re: [README] SSI FAQ's
« Reply #49 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() , '"';

Offline vsobral

  • Semi-Newbie
  • *
  • Posts: 10
Re: [README] SSI FAQ's
« Reply #50 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


« Last Edit: November 09, 2007, 09:31:57 AM by vsobral »

Offline vsobral

  • Semi-Newbie
  • *
  • Posts: 10
Re: [README] SSI FAQ's
« Reply #51 on: November 14, 2007, 01:29:58 PM »
somebody please?

Offline otectom

  • Semi-Newbie
  • *
  • Posts: 55
Re: [README] SSI FAQ's
« Reply #52 on: January 04, 2008, 10:08:00 PM »
is it possible to use SSI to add calendar events to another page of your site?

Offline fwitt

  • Full Member
  • ***
  • Posts: 479
  • Gender: Male
Re: [README] SSI FAQ's
« Reply #53 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.

Offline otectom

  • Semi-Newbie
  • *
  • Posts: 55
Re: [README] SSI FAQ's
« Reply #54 on: January 05, 2008, 01:08:30 PM »
Thank you!

Offline otectom

  • Semi-Newbie
  • *
  • Posts: 55
Re: [README] SSI FAQ's
« Reply #55 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

Offline fwitt

  • Full Member
  • ***
  • Posts: 479
  • Gender: Male
Re: [README] SSI FAQ's
« Reply #56 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/>';
}
}

Offline otectom

  • Semi-Newbie
  • *
  • Posts: 55
Re: [README] SSI FAQ's
« Reply #57 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?

Offline fwitt

  • Full Member
  • ***
  • Posts: 479
  • Gender: Male
Re: [README] SSI FAQ's
« Reply #58 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"));

Offline otectom

  • Semi-Newbie
  • *
  • Posts: 55
Re: [README] SSI FAQ's
« Reply #59 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.