News:

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

Main Menu

SSI to show the most popular topic from a specified board ?

Started by myaicons, January 27, 2008, 03:15:56 PM

Previous topic - Next topic

spottedhog

try this:


<?php
require('./forum/SSI.php');
$array ssi_topTopicsReplies($output_method 'array');

if (empty(
$array))

   echo 
'No topic posted';

foreach (
$array as $topics)

{
echo 
'

<div style="width:100%" class="option">

        '
$topics['icon'], '&nbsp;<strong>'$topics['subject'], '</strong><br />


<span style="font-size:x-small">Posted On:&nbsp;&nbsp;'
,$topics['time'], '</span><br />
<span class="option">'
$topics['body'],' <a href="'$topics['href'], '">Read more...</a></span></div><br />


<span style="font-size:smaller">'
$topics['link'], $topics['locked'] ? '' ' | ' $topics['comment_link'], ' | 


if (!$topics['
is_last'])

echo '
<hr style="width:50%;text-align:left; margin: 0 auto 0 auto" /><br />;

?>


and save it as a php file extention page, for example:  text.php

---you had some variables named $topic instead of $topics

myaicons

i got this error now:


Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/content/html/toptopicpost.php on line 27

line 27:
if (!$topics['is_last'])
i scratch your back you scratch my back...
funny thing about my back is its located on my...

spottedhog

I guess I did not look at your code closely enough... sorry.

You need to replace this line:
<span style="font-size:smaller">', $topics['link'], $topics['locked'] ? '' : ' | ' . $topics['comment_link'], ' |

with maybe this:

<span style="font-size:smaller">', $topics['link'], $topics['locked'] ? '' : ' | ' . $topics['comment_link'], ' </span>';

myaicons

um... now this:


Parse error: parse error, unexpected $ in /home/content/html/toptopicpost.php on line 31
i scratch your back you scratch my back...
funny thing about my back is its located on my...

spottedhog


myaicons




<?php
require('./sforum/SSI.php');
$array ssi_topTopicsReplies($output_method 'array');

if (empty(
$array))

   echo 
'No topic posted';

foreach (
$array as $topics)

{
echo 
'

<div style="width:100%" class="option">

        '
$topics['icon'], '&nbsp;<strong>'$topics['subject'], '</strong><br />


<span style="font-size:x-small">Posted On:&nbsp;&nbsp;'
,$topics['time'], '</span><br />
<span class="option">'
$topics['body'],' <a href="'$topics['href'], '">Read more...</a></span></div><br />


<span style="font-size:smaller">'
$topics['link'], $topics['locked'] ? '' ' | ' $topics['comment_link'], ' </span>';


if (!
$topics['is_last'])

echo 
'<hr style="width:50%;text-align:left; margin: 0 auto 0 auto" /><br />;

} ?>




i appreciate all the help  :)
i scratch your back you scratch my back...
funny thing about my back is its located on my...

spottedhog

see if this works:

<?php
require('./sforum/SSI.php');
$array ssi_topTopicsReplies($output_method 'array');
if (empty(
$array))
   echo 
'No topic posted';
   echo 
'
<table class="ssi_table">'
;
foreach ($array as $topics)
echo '
<tr>
<td align="left">
'
$topics['link'], '
</td>
<td>'
$topics['body'], '</td>
</tr>'
;
echo '
</table>'
;

?>


myaicons

that just gave me another :

Database Error
Please try again. If you come back to this error screen, report the error to an administrator


i think the previous code was more on the right track
i scratch your back you scratch my back...
funny thing about my back is its located on my...

spottedhog

Firstly, let's get one that is working, then modify it from there.  I looked over the SSI.php file, and the $num_topics variable was left out before.

Try this one:

<?php
require('./sforum/SSI.php');
$array ssi_topTopicsReplies($num_topics 10$output_method 'array');
if (empty(
$array))
   echo 
'No topic posted';
   echo 
'
<table class="ssi_table">'
;
foreach (
$array as $topics)
echo 
'
<tr>
<td align="left" valign="top">
'
$topics['link'], '
</td>
<td valign="top">'
$topics['body'], '</td>
</tr>'
;
echo 
'
</table>'
;

?>

It works for my local install.

I just added the valign so both lines would start at the top of the table cell.

myaicons

woo hoo!

that did it!!! :)

but i tried to add

$exclude_boards = array(1,2,3,4,5)

to exclude some boards from the results but that didnt work

i scratch your back you scratch my back...
funny thing about my back is its located on my...

spottedhog

In the SSI.php file, around line 542 find:

AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "

replace with:
AND b.ID_BOARD != $modSettings[recycle_board]" : ''
AND ID_BOARD != array(1,2,3,4,5)) . "


Try that....  I have not tested it, but it may work.

myaicons

nope... that didnt do anything...

i also tried modifying the actual ssi call (just in case i want to repeat it with different boards) but that didnt work for me either


<?php
require('./sforum/SSI.php');
$array ssi_topTopicsReplies($num_topics 1$output_method 'array'$exclude_boards = array(1,2,3,4,5,6));
if (empty(
$array))
   echo 
'No topic posted';
   echo 
'
<table class="ssi_table">'
;
foreach (
$array as $topics)
echo 
'
<tr>
<td align="left" valign="top">
'
$topics['link'], '
<br>
<br>'
$topics['body'], '</td>
</tr>'
;
echo 
'
</table>'
;

?>


either through exclusion or inclusion of boards?  whichever works....


secondly, the icon, date, poster, and comments wont work for it either.... im trying to make it look as close to the board news output as much as possible 

$topics['icon'], $topics['comment_link'], etc...
i scratch your back you scratch my back...
funny thing about my back is its located on my...

spottedhog

Ok... now you are asking more than that ssi function does.

If you are wanting these kinds of outputs, you will probably need to create your own MySQL query and write the outputs from that, thus bypassing SSI.php functions.

Quotesecondly, the icon, date, poster, and comments wont work for it either.... im trying to make it look as close to the board news output as much as possible

$topics['icon'], $topics['comment_link'], etc...

Those do not work because that ssi function does not "draw out" those variables or database inputs.

Determine what you are fully wanting, then create the query that will supply the needed variables.

myaicons

that is what i feared  :(

i guess those are not necessary... but thanks for all the help!  :D

...all except for the specified board(s) to pull the popular topic from...
would be nice to have...
i scratch your back you scratch my back...
funny thing about my back is its located on my...

spottedhog

don't fear it....  try things....

I would highly recommend downloading this software below.  You can make your own computer a webserver and test out code.  If you have Windoz, you can make a USB thumb drive a webserver, and then test out your code.

http://www.apachefriends.org/en/xampp.html

Personally, I have Kubuntu Linux installed on my dual-boot laptop, so I am able to start up my local webserver from the hard drive and test out all things related to html, php, and mysql.

All that you need to know to make the query you want is contained inside that SSI.php file.  It is just a matter of determining what you want, create the MySQL query for it, and then putting your output into an array.  I know it sounds a bit hard, but I know all you need to know for working examples are in the SSI.php file.

If/when you can write your own query and display the results, you then have a great working knowledge of SMF and other php/mysql applications.

Maybe someone will volunteer to write it for you....  who knows.

myaicons

i scratch your back you scratch my back...
funny thing about my back is its located on my...

Advertisement: