News:

Wondering if this will always be free?  See why free is better.

Main Menu

why doesnt this recentposts code work?

Started by mama, January 22, 2006, 07:46:48 PM

Previous topic - Next topic

mama

<?php $array ssi_recentTopics($num_recent 10$exclude_boards null$output_method 'echo'); 
 
<table border="0" class="ssi_table">';
foreach ($posts as $post)
echo 
<tr>

<td valign="top">


<a href="'
$post['href'], '">'$post['subject'], '</a>

'
$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">
<span class="small">'
$post['time'], '</span>
</td>
</tr>;


    </table>'
;


   
   
   ?>

JayBachatero

Try this.

<?php $posts ssi_recentTopics($num_recent 10$exclude_boards null$output_method 'echo'); 
 
echo ' <table border="0" class="ssi_table">';
foreach ($posts as $post)
echo '
<tr>

<td valign="top">


<a href="'
$post['href'], '">'$post['subject'], '</a>

'
$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">
<span class="small">'
$post['time'], '</span>
</td>
</tr>;


    </table>'
;


   
   
   ?>


-JayBachatero
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

mama

I´m getting this warning wwhen I use the code above:

Warning: Invalid argument supplied for foreach() in line 58
And the text in line 58 is: foreach ($posts as $post)

JayBachatero

$posts = ssi_recentTopics($num_recent = 10, $exclude_boards = null, $output_method = 'echo');  change to $posts = ssi_recentTopics($num_recent = 10, $exclude_boards = null, $output_method = 'array');

-JayBachatero
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

mama

thanks for the help, it works great. =)

I noticed now when I saw new post coming in, if I can place numbers of replies between link and date?

JayBachatero

I was looking ang couldn't find nothing about this.  With a few changes to SSI.php.  Also use this snippet it prints out the stuff more cleaner :)


<?php
$posts 
ssi_recentTopics($num_recent 10$exclude_boards null$output_method 'array');
 
echo '
<table border="0" class="ssi_table">'
;
foreach ($posts as $post)
        {
echo '
<tr>
<td valign="top">
                                        <a href="'
$post['href'], '">'$post['subject'], '</a>'$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">
<span class="small">'
$post['time'], '</span>
</td>
</tr>'
;
          }

    echo '
</table>'
;
?>



If you want to see other stuff that you can do just put this before ?>
echo '<pre>';
print_r($posts);
echo '</pre>';

-JayBachatero
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

mama

#6
Quote from: JayBachatero on January 22, 2006, 08:39:35 PM
I was looking ang couldn't find nothing about this.  With a few changes to SSI.php.  Also use this snippet it prints out the stuff more cleaner :)

If you want to see other stuff that you can do just put this before ?>
echo '<pre>';
print_r($posts);
echo '</pre>';

-JayBachatero

My post over was some typing error. ;)
I meant: If someone post a new post on "recenttopic" I get an image(new.gif) to tell me that someone have posted. But I wonder if I can place a "number of replies" in the middle(between topic and date).

Now I tested to place those code you showed me and I get this:

Array
(
    [0] => Array
        (
            [board] => Array
                (
                    [id] => 7
                    [name] => Nyheter
                    [href] => forum/index.php?board=7.0
                    [link] => Nyheter
                )

            [topic] => 19
            [poster] => Array
                (
                    [id] => 1
                    [name] => mattias
                    [href] => forum/index.php?action=profile;u=1
                    [link] => mattias
                )

            [subject] => mupp nyhet4
            [short_subject] => mupp nyhet4
            [preview] => Well, this doesn't seem like true ssi to me anyway, mainly just importing functions from the board to other aspects of a si...
            [time] => 23 jan 2006, 01:51
            [timestamp] => 1137977506
            [href] => forum/index.php?topic=19.msg27;topicseen#new
            [link] => mupp nyhet4
            [new] => 1
            [new_from] => 0
            [icon] => xx
        )

and it continues


) <---stops here


I´m using smf 1.1 rc2.

mama

I´m starting to understand what you wrote. =)
That information I got when I used your "snippet" is what code I can use with my board, but I didn´t see anything about the replies number. :(

JayBachatero

Yes exactly it shows you extra stuff.  Like I stated it doesn't show number of replies. 
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

mama

If I understand it correctly there is no code/mod to show replies. But if I want replies number, is it hard to do? (I have very little php knowledge)

JayBachatero

Yea there is no way to do this unless you modify SSI.php to do so.  I'm not sure how hard this would be to do.

-JayBachatero
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

mama

ok, thanks for this info.
I hope, showing the replies, will come to smf 1.1 rc3. :)

JayBachatero

Well there won't be more feature addition to the 1.1 Line.  The next release will be 1.1 Final.  If you want you can make it a feature request for the next version of SMF. :)
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

mama

#13
I will do a request about this very important thing. :)


Advertisement: