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

myaicons


is it possible to have an SSI to show the most popular topic from a specified board?

either based on posts or views...

... i know there is the Top Topics SSI

Top Topics by View Function: <?php ssi_topTopicsViews(); ?>
which lists the links to the topics

but instead... something that shows the whole message... not just the message link...


thanks in advance! 


P.S. and a random topic from a specific board?


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

myaicons

so... is this question too easy to spend time answering? or too hard to answer?   :)
i scratch your back you scratch my back...
funny thing about my back is its located on my...

jamesk

Is it possible -- yes.  With the default SSI.php -- I don't think so.

Is it easy or hard?  Depends on who you ask...  :P

I haven't tried and/or verified but...
If you're not a MySQL person, the easy way is to use the existing ssi_topTopics() to get the $topics['id'] and once you have the topic IDs, you can retrieve the message body by following this thread (bottom half):

http://www.simplemachines.org/community/index.php?topic=214231.msg1377171#msg1377171

If you ARE a MySQL and/or database person, then you can write a query from scratch...


myaicons

Quote from: jamesk on January 29, 2008, 10:27:45 PM<br />Is it possible -- yes.  With the default SSI.php -- I don't think so.  Is it easy or hard?  Depends on who you ask...

ahhh... a brave one ! yay... so am i asking the right person? lol

nope... not a database person...
i prefer the easy route of modifying the ssi call...

i wouldnt imagine it wouldnt be too far from the ssi_topTopics()
i scratch your back you scratch my back...
funny thing about my back is its located on my...

spottedhog

I will take a stab at it....

This will require you to make 2 changes in the SSI.php file, however, it should not change any part of the original output of SSI.php functions. 

What you are wanting is for the ssi_topTopics(); function to add a request in the database query for the body field from the messages table.

In the original 1.1.4 SSI.php file, in the ssi_topTopics(); function,
find around line 536:
SELECT m.subject, m.ID_TOPIC, t.numViews, t.numReplies
replace with:
SELECT m.subject, m.ID_TOPIC, t.numViews, t.numReplies, m.body

OK... the body field should be available to get the data.  Now we need to put it in the $topics variable....

Around line 551 find:
'id' => $row['ID_TOPIC'],
replace with:

'id' => $row['ID_TOPIC'],
'body' => $row['body'],


Now you should be able to use $output_method = 'array' and call the body field.

myaicons

sounds like that would make sense...  :)

but i guess i didnt clarify from my previous post that i want the body from the top topics by view or by reply

<?php ssi_topTopicsViews(); ?>

or

<?php ssi_topTopicsReplies(); ?>


would it work the same way if i added your code to those functions?


the ssi would look like this:  ??

Quote<?php ssi_topTopicsReplies($num_recent = 1, $exclude_boards = array(1,2,3), $output_method = 'm.body' ); ?>

(if i exluded a few boards)


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

spottedhog

please reread my post above....  you did not understand it very well....

To help you out a little....  there are only 2 ways to output....  by 'array' or by 'echo'

myaicons

actually... its because i literally do not  understand it...  :-[

im very new and still learning to php and all this coding...


(im on chapter 2 of teach yourself php in 10 mins) lol

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

spottedhog

Here is a sample using the output method 'array' :

$array = ssi_boardNews($board = $newsboard, $limit = 5, $start = null, $length = 500, $output_method = 'array');

     

if (empty($array))

   echo _NOTOPICSPOSTED;



foreach ($array as $news)

{

echo '

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

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

<span style="font-size:x-small">Posted On:&nbsp;&nbsp;', $news['time'], '</span><br />

<span class="option">', $news['body'],' <a href="', $news['href'], '">', _READMORE ,'</a></span></div><br />

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

<a href="forum/index.php?action=post;board=', $newsboard ,'">', _POSTNEWSARTICLE ,'</a></span><br /><br />';



if (!$news['is_last'])

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



}

myaicons

yikes... completely lost now...


<?php ssi_topTopicsReplies($output_method= 'array'); ?>
i scratch your back you scratch my back...
funny thing about my back is its located on my...

spottedhog

yes....  then you can make something similar to the example I posted.  You will need to see what fields are available in the ssi_toptopics...

myaicons

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

spottedhog

keep testing.....

and when you post a reply, please copy/paste the error here.

myaicons

this is the error i get everytime:

Database Error
Please try again. If you come back to this error screen, report the error to an administrator. 
i scratch your back you scratch my back...
funny thing about my back is its located on my...

spottedhog

do you have:

require_once("path_to/SSI.php");

at the top of your page?

and if so, is the path correct?

myaicons

yup...
that i know i have right

<?php require('./forum/SSI.php'); ?>

its the rest that is not quite right i think
i scratch your back you scratch my back...
funny thing about my back is its located on my...

spottedhog

hmmmm....  can you post your page code here?

also, is your ssi function inside the <?  ?>   ???

myaicons



<?php

$array 
ssi_topTopicsReplies($output_method 'array');

     


if (empty(
$array))

   echo 
_NOTOPICSPOSTED;



foreach ($array as $topics)

{

echo '

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

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

<span style="font-size:x-small">Posted On:&nbsp;&nbsp;'
,$topic['time'], '</span><br />

<span class="option">'
$topic['body'],' <a href="'$topic['href'], '">'_READMORE ,'</a></span></div><br />

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


if (!$topic['
is_last'])

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



} ?>



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

spottedhog

you need to put this line immediately after <?php

require_once("path_to/SSI.php");

replace "path_to" with the actual path to your SSI.php file.

myaicons

i actually have this right above it


<?php require('./forum/SSI.php'); ?>
i scratch your back you scratch my back...
funny thing about my back is its located on my...

Advertisement: