News:

Join the Facebook Fan Page.

Main Menu

Some SSI questions...

Started by buddha, August 10, 2004, 07:56:19 AM

Previous topic - Next topic

buddha

What an awesome peice of software, congratulations to all who have worked on it. However, I have a few questions as I am struggling to customize SSI stuff.

Here goes....

1. I noticed that Ignatius has improved the word truncation for ssi_boardnews: Is this going to be featured in future versions of SSI.php, or shall I go ahead and make the modification?

2. I've customised the layout of the ssi_recenttopics function by editing SSI.php, which is obviously messy. Is there a way to do it a more sensible way? I've read through the SSI tutorials but haven't worked out how to apply the same priniples to this. I want to stop it displaying a link to the board the post was made in, amongst other minor things.

3. Is there a way to truncate the output of ssi_recenttopcs, as a long subject title will throw the content of my front page out.


Any help will be hugely appreciated! :)

[Unknown]

Quote from: Buddha on August 10, 2004, 07:56:19 AM
1. I noticed that Ignatius has improved the word truncation for ssi_boardnews: Is this going to be featured in future versions of SSI.php, or shall I go ahead and make the modification?

No offense to its author, but that is one ugly piece of code.  Personally, I don't think this is as necessary as to warrant such function-bloat.

Quote2. I've customised the layout of the ssi_recenttopics function by editing SSI.php, which is obviously messy. Is there a way to do it a more sensible way? I've read through the SSI tutorials but haven't worked out how to apply the same priniples to this. I want to stop it displaying a link to the board the post was made in, amongst other minor things.

Lamper didn't really understand the proper way to do it when he first wrote the tutorials.  The best way is to use the alternate output method - this basically means passing 'array' as the last parameter to the function. (in the case of ssi_recentTopics, this means ssi_recentTopics(8, array(), 'array'))

If you do this, it will return an array of information.  The best way to understand this information is to use the print_r() function on it, like so:

$array = ssi_recentTopics(8, array(), 'array');
print_r($array);

You can copy the output code from SSI.php like so:

$posts = ssi_recentTopics(8, array(), 'array');

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">
<a href="', $post['href'], '">', $post['subject'], '</a>
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.from' . $post['newtime'] . ';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>';


This is by FAR the best way to do it, because it makes upgrading much much easier and gives you more "hands on" control of the layout.

Quote3. Is there a way to truncate the output of ssi_recenttopcs, as a long subject title will throw the content of my front page out.

You can use width, and then white-space: nowrap; in the css... such as:

$posts = ssi_recentTopics(8, array(), 'array');

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">
<a href="', $post['href'], '" style="width: 40ex; white-space: nowrap; overflow: hidden;">', $post['subject'], '</a>
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.from' . $post['newtime'] . ';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>';


You can also mess with $post['subject'] manually....

But, if you want it to trail off like on the board index, replace $post['subject'] with $post['short_subject'].

-[Unknown]

buddha

Unknown, you are an absolute legend, cheers for that.

I am nearly there, but a couple of things...

1. I want to display the poster's name, but without the hyperlink to their profile. I presume I would have to edit the following  line:

', $txt[525], ' ', $post['poster']['link'], '

But I'm not having any luck. Anyone have any ideas?

2. The truncation of output works perfectly using $post['short_subject'],  and the length happens to be just what I need. Nevertheless, is there a way of specifying the number of characters after which it trails off?

3. Finally, and I'm being a bit picky here, but is there a way to remove the seconds from the post time in ssi_recenttopics? So it just displays hours and minutes?

P.S. Since I'm in stupidly fussy mode, does anyone know how prevent a page using ssi_logout from going to the forum page, i.e. so that it logs out of the forum but stays on my home page?

P.P.S. This is a non-existent issue with my site, but potentially it could happen... if a user has a very long username they will throw out the content on my SSI pages. Is there a way to truncate their display name in SSI after X number of characters? I'm refering to ssi_welcome and ssi_whosonline.

Well that's it, the final of my SSI issues getting my new site online. I will big you all up when I go live. :) Cheers again...

[Unknown]

Quote from: Buddha on August 11, 2004, 11:25:26 AM
Unknown, you are an absolute legend, cheers for that.

I am nearly there, but a couple of things...

1. I want to display the poster's name, but without the hyperlink to their profile. I presume I would have to edit the following  line:

', $txt[525], ' ', $post['poster']['link'], '

$post['poster']['link'] -> $post['poster']['name']...

QuoteBut I'm not having any luck. Anyone have any ideas?

2. The truncation of output works perfectly using $post['short_subject'],  and the length happens to be just what I need. Nevertheless, is there a way of specifying the number of characters after which it trails off?

Not currently.

Quote3. Finally, and I'm being a bit picky here, but is there a way to remove the seconds from the post time in ssi_recenttopics? So it just displays hours and minutes?

That's your time format string.

QuoteP.S. Since I'm in stupidly fussy mode, does anyone know how prevent a page using ssi_logout from going to the forum page, i.e. so that it logs out of the forum but stays on my home page?

Yes, use $_SESSION['logout_url'].. I think.  Check SSI.php.

QuoteP.P.S. This is a non-existent issue with my site, but potentially it could happen... if a user has a very long username they will throw out the content on my SSI pages. Is there a way to truncate their display name in SSI after X number of characters? I'm refering to ssi_welcome and ssi_whosonline.

Well that's it, the final of my SSI issues getting my new site online. I will big you all up when I go live. :) Cheers again...

Not currently for the last issue either.

-[Unknown]

buddha

Thanks for your help yet again.  :) I've got the logging in and out issue on SSI pages working, by using the following code:

<?php ssi_login('../new/index.php'); ?>

However, although it's fine on various SSI pages, when I go to the forum and log in or out from there it will take me back to the previous SSI page I was on. Quite amusing but a bit of a nusance for my users. Any ideas on how to fix it?

Also, I didn't really understand how to change my time format string. I would like the bulletin board to display the full time of each post (including seconds), but my SSI pages to omit seconds. Is there a way to do this? If it's a lot of hassle just say so cos I'm being picky here!  ;)

[Unknown]

Hmm, you'd have to make all of SSI.php use a function other than timeformat() for its time formatting needs.

And, yes, that's a side effect of this method.  I suppose you could fix it by adding the following near the top of BoardIndex.php: (not inside the comments, just above "function BoardIndex()")
$_SESSION['login_url'] = $scripturl;

-[Unknown]

CaelDorwin

Does this code actually work?

Quote from: Buddha on August 20, 2004, 10:40:16 PM
<?php ssi_login('../new/index.php'); ?>

  I'm trying it on my site and can't seem to get the "redirect to a page other than the forum's index.php" working...  Is there a mod or something else that I could be missing? 

Thanks...

[Unknown]

CaelDorwin, are you sure you're using RC1?

-[Unknown]

CaelDorwin

Here's my support info...


Support Information
Version Information:
Forum version: SMF 1.0 Beta 5 Public (more detailed)
Current SMF version: SMF 1.0 RC1
PHP version: 4.3.3
MySQL version: 3.23.58
Server version: Apache
GD version: bundled (2.0.15 compatible)


Looks like it's RC1.

Quote from: [Unknown] on August 21, 2004, 01:45:25 AM
CaelDorwin, are you sure you're using RC1?

-[Unknown]

[Unknown]

Quote from: CaelDorwin on August 21, 2004, 02:16:30 AM
Here's my support info...


Forum version: SMF 1.0 Beta 5 Public (more detailed)
Current SMF version: SMF 1.0 RC1


In other words:

Hi.  Your version is SMF 1.0 Beta 5 Public.
The most recent version in SMF 1.0 RC1.

You'll notice that "SMF 1.0 Beta 5 Public" is (or should be!) red.  This indicated it is out of date.

-[Unknown]

CaelDorwin

Ahh... gotcha... updating now... Thx.

buddha

Awesome, cheers for that! It said something about an undefined variable when I put it above function BoardIndex(), so I put it under the first 2 lines where the variables are defined. Seems to work fine. I also added $_SESSION['logout_url'] = $scripturl;, and it works a treat. I don't know a thing about PHP (or any other language for that matter) I just look at your code and try to guess what's happening, so cheers for the guidance. :)

Quote from: [Unknown] on August 20, 2004, 11:29:39 PM
Hmm, you'd have to make all of SSI.php use a function other than timeformat() for its time formatting needs.

Does this mean it's going to be a big hassle then? Haha, don't worry I will leave it for now.

Re: the word truncation so that BBC code doesn't get cut off in SSI, do you know if this will be something for a future version of SMF?

Advertisement: