Advertisement:

Author Topic: SSI to show the most popular topic from a specified board ?  (Read 7688 times)

Offline myaicons

  • Jr. Member
  • **
  • Posts: 228
  • Gender: Female
SSI to show the most popular topic from a specified board ?
« on: January 27, 2008, 03:15:56 PM »

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...

Offline myaicons

  • Jr. Member
  • **
  • Posts: 228
  • Gender: Female
Re: SSI to show the most popular topic from a specified board ?
« Reply #1 on: January 29, 2008, 10:03:10 PM »
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...

Offline jamesk

  • Full Member
  • ***
  • Posts: 411
Re: SSI to show the most popular topic from a specified board ?
« Reply #2 on: January 29, 2008, 10:27:45 PM »
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...


Offline myaicons

  • Jr. Member
  • **
  • Posts: 228
  • Gender: Female
Re: SSI to show the most popular topic from a specified board ?
« Reply #3 on: January 29, 2008, 11:00:14 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()
« Last Edit: January 29, 2008, 11:04:29 PM by myaicons »
i scratch your back you scratch my back...
funny thing about my back is its located on my...

Offline spottedhog

  • Sr. Member
  • ****
  • Posts: 782
  • Gender: Male
Re: SSI to show the most popular topic from a specified board ?
« Reply #4 on: January 30, 2008, 05:29:00 PM »
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:
Code: [Select]
SELECT m.subject, m.ID_TOPIC, t.numViews, t.numRepliesreplace with:
Code: [Select]
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:
Code: [Select]
'id' => $row['ID_TOPIC'],replace with:
Code: [Select]
'id' => $row['ID_TOPIC'],
'body' => $row['body'],

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

Offline myaicons

  • Jr. Member
  • **
  • Posts: 228
  • Gender: Female
Re: SSI to show the most popular topic from a specified board ?
« Reply #5 on: January 30, 2008, 06:27:10 PM »
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)


« Last Edit: January 30, 2008, 06:31:10 PM by myaicons »
i scratch your back you scratch my back...
funny thing about my back is its located on my...

Offline spottedhog

  • Sr. Member
  • ****
  • Posts: 782
  • Gender: Male
Re: SSI to show the most popular topic from a specified board ?
« Reply #6 on: January 30, 2008, 06:35:55 PM »
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'
« Last Edit: January 30, 2008, 06:44:49 PM by spottedhog »

Offline myaicons

  • Jr. Member
  • **
  • Posts: 228
  • Gender: Female
Re: SSI to show the most popular topic from a specified board ?
« Reply #7 on: January 30, 2008, 06:51:31 PM »
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...

Offline spottedhog

  • Sr. Member
  • ****
  • Posts: 782
  • Gender: Male
Re: SSI to show the most popular topic from a specified board ?
« Reply #8 on: January 30, 2008, 06:58:59 PM »
Here is a sample using the output method 'array' :

Code: [Select]
$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 />';



}

Offline myaicons

  • Jr. Member
  • **
  • Posts: 228
  • Gender: Female
Re: SSI to show the most popular topic from a specified board ?
« Reply #9 on: January 30, 2008, 07:09:19 PM »
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...

Offline spottedhog

  • Sr. Member
  • ****
  • Posts: 782
  • Gender: Male
Re: SSI to show the most popular topic from a specified board ?
« Reply #10 on: January 30, 2008, 07:30:42 PM »
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...

Offline myaicons

  • Jr. Member
  • **
  • Posts: 228
  • Gender: Female
Re: SSI to show the most popular topic from a specified board ?
« Reply #11 on: January 30, 2008, 08:23:20 PM »
i keep getting a database error  :(
i scratch your back you scratch my back...
funny thing about my back is its located on my...

Offline spottedhog

  • Sr. Member
  • ****
  • Posts: 782
  • Gender: Male
Re: SSI to show the most popular topic from a specified board ?
« Reply #12 on: January 30, 2008, 08:27:52 PM »
keep testing.....

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

Offline myaicons

  • Jr. Member
  • **
  • Posts: 228
  • Gender: Female
Re: SSI to show the most popular topic from a specified board ?
« Reply #13 on: January 30, 2008, 08:39:21 PM »
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...

Offline spottedhog

  • Sr. Member
  • ****
  • Posts: 782
  • Gender: Male
Re: SSI to show the most popular topic from a specified board ?
« Reply #14 on: January 30, 2008, 08:45:43 PM »
do you have:

require_once("path_to/SSI.php");

at the top of your page?

and if so, is the path correct?

Offline myaicons

  • Jr. Member
  • **
  • Posts: 228
  • Gender: Female
Re: SSI to show the most popular topic from a specified board ?
« Reply #15 on: January 30, 2008, 09:08:13 PM »
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...

Offline spottedhog

  • Sr. Member
  • ****
  • Posts: 782
  • Gender: Male
Re: SSI to show the most popular topic from a specified board ?
« Reply #16 on: January 30, 2008, 09:17:14 PM »
hmmmm....  can you post your page code here?

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

Offline myaicons

  • Jr. Member
  • **
  • Posts: 228
  • Gender: Female
Re: SSI to show the most popular topic from a specified board ?
« Reply #17 on: January 30, 2008, 09:32:40 PM »
Code: [Select]

<?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...

Offline spottedhog

  • Sr. Member
  • ****
  • Posts: 782
  • Gender: Male
Re: SSI to show the most popular topic from a specified board ?
« Reply #18 on: January 30, 2008, 09:49:05 PM »
you need to put this line immediately after <?php

Code: [Select]
require_once("path_to/SSI.php");
replace "path_to" with the actual path to your SSI.php file.

Offline myaicons

  • Jr. Member
  • **
  • Posts: 228
  • Gender: Female
Re: SSI to show the most popular topic from a specified board ?
« Reply #19 on: January 30, 2008, 09:50:33 PM »
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...