News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Question on SSI

Started by t3ngu, October 29, 2009, 05:13:49 PM

Previous topic - Next topic

Arantor

No, I don't think it's the tables. It's something else.

Try doing a print_r of $array to see what the physical content of it is.

t3ngu

Yeah this is weird, I just tested again and short_subject works if I edit SSI.php's display properties, but not on index.php of my website. I tried using subject instead of short_subject, and it now shows:

[(category name should be here, but it's not)]      October 29, 2009, 08:25:49 PM
Thread name
by Poster

And sorry but I'm not familiar with print_r. How would I use it?

Arantor

You'd use:
print_r($array);

Will give you a lot of output, best viewed by viewing the HTML source in the browser though, since it's not exactly nicely formatted otherwise.

t3ngu

Array (

Arantor

Hmm. Neither short_subject or board is listed at all.

Which function are you calling again?

t3ngu

I put in
print_r($array);
Exactly as you posted.

The code hasn't changed since the last time I posted it.

Arantor

So, which SSI function are you calling, exactly?

If it's ssi_boardNews, there's the issue - boardNews won't populate the board info because you can only get it from one board at a time. And generally it won't expect to generate a short subject either.

t3ngu

Yeah, it's boardNews. Which one should I be using instead? I know recentTopics can do it but I want to see the latest posts, not threads.

ディン1031

my first suggest would be ssi_recentPosts.
Quote
function ssi_recentPosts($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo')

But it does not work in the same way as boardNews ;).(Board News load only the first post of the latest topics in the given news board).

Support only via MOD Thread! NO PM Support!
My Forum: ayu][kult Forum
My Mods: My Small Mod Collection
My Parser: DIN1031's ModParser
Current Info: More away the next days, because i've to much work to do :x

t3ngu

Oh wow, I can't believe I was making such an obvious mistake. Sorry about the trouble, it works now.

I do have one problem. This is the current format for ssi_recentPosts:
echo '
<table border="0" class="ssi_table">';
foreach ($posts as $post)
echo '
<tr>
<td align="top" valign="top" nowrap="nowrap">
[', $post['board']['link'], ']
</td>
<td align="right" nowrap="nowrap">
', $post['time'], '
</td>
<tr>
<td valign="left">
&nbsp&nbsp -<a href="', $post['href'], '">', $post['short_subject'], '</a>
', $txt['by'], ' ', $post['poster']['link'], '
', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '
</td>
</tr>';
echo '
</table>';
}


so if the thread name is long, it displays like this:

[Board Name]                                October 29, 2009, 08:25:49 PM
   -Really Long Thread Name by
Poster

Since there are two tables and it's divided down the middle, the poster name will go down to a third row if the thread title is too long. If I wanted to show an array with the Board Name and Post date separated like it is now, but the rest in ONE ROW, how would I write it?

Arantor

The td in the second row (where the poster stuff is), add colspan="2" to it so it spans both table columns.

t3ngu

echo '
<table border="0" class="ssi_table">';
foreach ($posts as $post)
echo '
<tr>
<td align="top" valign="top" nowrap="nowrap">
[', $post['board']['link'], ']
</td>
<td align="right" nowrap="nowrap">
', $post['time'], '
</td>
<tr>
<td colspan="2">
&nbsp&nbsp -<a href="', $post['href'], '">', $post['short_subject'], '</a>
', $txt['by'], ' ', $post['poster']['link'], '
', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '
</td>
</tr>';
echo '
</table>';


Like this? It's not working.
I also don't want to change around SSI.php too much. Would it be easier to just write an array with a table for the forum category and time, and a normally displayed row below it? If so, how would I write the array?

Thanks for putting up with my questions by the way.

Arantor

There should be a closing </tr> before the second row starts.

Generally you shouldn't have to modify SSI.php at all; you can export using an array generally back to your own code.

Then it's mostly just a copy of the above anyway.

t3ngu

Hm, added </tr> before the second <tr> and still nothing. I have a feeling I'm missing something obvious again.

t3ngu

Yeah it was an obvious mistake on my part again, thanks a lot for the help Arantor, it's working perfectly now.

t3ngu

Sorry about this, but I have another question. How would I display the previous code as an array? It's:

<table border="0" class="ssi_table">';
   foreach ($posts as $post)
      echo '
         <tr>
            <td align="top" valign="top" nowrap="nowrap">
               [', $post['board']['link'], ']
            </td>
                        <td align="right" nowrap="nowrap">
               ', $post['time'], '
            </td>
         <tr>
            <td colspan="2">
               &nbsp&nbsp -<a href="', $post['href'], '">', $post['short_subject'], '</a>
               ', $txt['by'], ' ', $post['poster']['link'], '
               ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '
            </td>
         </tr>';
   echo '
      </table>';


I used the above to edit SSI.php, but want to change the "echo" display instead of messing with the SSI files. I tried just changing echo to array, but it will error with the tags for the tables.
<?php
ssi_recentPosts
($num_recent 5$exclude_boards = array(23), $include_boards null$output_method 'array')

<
table border="0" class="ssi_table">';
   foreach ($posts as $post)
      echo '
         
<tr>
            <
td align="top" valign="top" nowrap="nowrap">
               [
', $post['board']['link'], ']
            </
td>
                        <
td align="right" nowrap="nowrap">
               
', $post['time'], '
            
</td>
         <
tr>
            <
td colspan="2">
               &
nbsp&nbsp -<a href="', $post['href'], '">', $post['short_subject'], '</a>
               
', $txt['by'], ' ', $post['poster']['link'], '
               ', $post['
new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '
            
</td>
         </
tr>';
   echo '
      
</table>';
?>


How would I change the above to show as "array" without it erroring?

Arantor

Couple of minor tweaks, but you'll be able to compare them to see what changed; just to make it legal PHP.

<?php
$posts 
ssi_recentPosts($num_recent 5$exclude_boards = array(23), $include_boards null$output_method 'array');

echo 
'<table border="0" class="ssi_table">';
   foreach (
$posts as $post)
      echo 
'
         <tr>
            <td align="top" valign="top" nowrap="nowrap">
               ['
$post['board']['link'], ']
            </td>
                        <td align="right" nowrap="nowrap">
               '
$post['time'], '
            </td>
         <tr>
            <td colspan="2">
               &nbsp&nbsp -<a href="'
$post['href'], '">'$post['short_subject'], '</a>
               '
$txt['by'], ' '$post['poster']['link'], '
               '
$post['new'] ? '' '<a href="' $scripturl '?topic=' $post['topic'] . '.msg' $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' $settings['lang_images_url'] . '/new.gif" alt="' $txt['new'] . '" border="0" /></a>''
            </td>
         </tr>'
;
   echo 
'
      </table>'
;
?>

t3ngu

Thanks again for the quick reply Arrantor, that worked perfectly.

Arantor


Advertisement: