Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: mama - tammikuu 22, 2006, 07:46:48 IP

Otsikko: why doesnt this recentposts code work?
Kirjoitti: mama - tammikuu 22, 2006, 07:46:48 IP
<?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>'
;


   
   
   ?>
Otsikko: Re: why doesnt this recentposts code work?
Kirjoitti: JayBachatero - tammikuu 22, 2006, 07:58:05 IP
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
Otsikko: Re: why doesnt this recentposts code work?
Kirjoitti: mama - tammikuu 22, 2006, 08:03:55 IP
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)
Otsikko: Re: why doesnt this recentposts code work?
Kirjoitti: JayBachatero - tammikuu 22, 2006, 08:05:17 IP
$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
Otsikko: Re: why doesnt this recentposts code work?
Kirjoitti: mama - tammikuu 22, 2006, 08:21:25 IP
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?
Otsikko: Re: why doesnt this recentposts code work?
Kirjoitti: JayBachatero - tammikuu 22, 2006, 08:39:35 IP
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
Otsikko: Re: why doesnt this recentposts code work?
Kirjoitti: mama - tammikuu 23, 2006, 04:57:16 AP
Lainaus käyttäjältä: JayBachatero - tammikuu 22, 2006, 08:39:35 IP
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.
Otsikko: Re: why doesnt this recentposts code work?
Kirjoitti: mama - tammikuu 23, 2006, 04:26:22 IP
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. :(
Otsikko: Re: why doesnt this recentposts code work?
Kirjoitti: JayBachatero - tammikuu 24, 2006, 01:35:41 AP
Yes exactly it shows you extra stuff.  Like I stated it doesn't show number of replies. 
Otsikko: Re: why doesnt this recentposts code work?
Kirjoitti: mama - tammikuu 24, 2006, 04:56:58 AP
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)
Otsikko: Re: why doesnt this recentposts code work?
Kirjoitti: JayBachatero - tammikuu 24, 2006, 08:18:27 AP
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
Otsikko: Re: why doesnt this recentposts code work?
Kirjoitti: mama - tammikuu 24, 2006, 05:02:39 IP
ok, thanks for this info.
I hope, showing the replies, will come to smf 1.1 rc3. :)
Otsikko: Re: why doesnt this recentposts code work?
Kirjoitti: JayBachatero - tammikuu 24, 2006, 05:18:26 IP
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. :)
Otsikko: Re: why doesnt this recentposts code work?
Kirjoitti: mama - tammikuu 24, 2006, 05:19:42 IP
I will do a request about this very important thing. :)