Advertisement:

Author Topic: Thank-O-Matic (Updated for SMF 2.0.4)  (Read 1416890 times)

Offline Kindred

  • Support Specialist
  • SMF Master
  • *
  • Posts: 31,383
  • Gender: Male
    • wagner999 on Facebook
    • @Kindred_999 on Twitter
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support forums.  Thank you.

Offline Acer1963

  • Newbie
  • *
  • Posts: 1
Re: Thank-O-Matic (Updated for SMF 2.0.4)
« Reply #2161 on: April 08, 2013, 11:58:32 AM »
My English is not so good ... sorry! You can also set the button down? If so how can this be done?
Greeting Acer1963

Offline Skaty

  • Jr. Member
  • **
  • Posts: 306
Re: Thank-O-Matic (Updated for SMF 2.0.4)
« Reply #2162 on: April 12, 2013, 06:09:17 PM »
Working on a very custom layout and am using this mod to upvote posts.

Just wondering if there is a way to get the "most thanked" post ID from within "Display.template.php". I need to show a link to it in the header (regardless of the page it's on).

Cheers,
Josh

UPDATE: I can do it like this, but don't really like doing loops when there might be a heap of messages

Code: [Select]
  // Count up the thanks and work out if we have a winning post
  $bigthx = 0;
  foreach($context['thank_you_post'] as $thxmsgid => $thxpost) {
    if(is_numeric($thxmsgid)) {
      $thisthx = count($thxpost['fulllist']);
      if($thisthx > $bigthx) {
        $bigthx   = $thisthx;
        $bigthxid = $thxmsgid;
      }
    }
  }
  // $scripturl.'?topic='.$context['current_topic'].'msg'.$bigthxid.'#msg'.$bigthxid
Hi Josh
That SQL query will retrieve the record that has the maximum number of "ThankYous"
I tested that with my phpmyadmin and works fine.
Then you may use the values for displaying Poster Title and construct a link to the thread
`thank_you_post_counter` contains the number of "ThankYous"

Please note that some columns may differ from your `smf_messages` table, due to the various modifications installed. Clear out from SELECT, the columns you do not need.

Code: [Select]

SELECT `id_msg` , `id_topic` , `id_board` , `poster_time` , `id_member` , `id_msg_modified` , `subject` , `poster_name` , `poster_email` , `poster_ip` , `smileys_enabled` , `modified_time` , `modified_name` , `body` , `icon` , `hiddenOption` , `hiddenValue` , `hiddenInfo` , `thank_you_post` , `thank_you_post_counter` , `approved`
FROM `smf_messages`
ORDER BY thank_you_post_counter DESC
LIMIT 1




Also remember that you may easily display top 5 users Thankyou statistics.
That will increase competition among users to up-vote threads

Code: [Select]

<?php ssi_thankYouPostTopResived(); ?>
<?php ssi_thankYouPostTopGiven(); ?>


I want to show most thanked post but i didnt get how to add in my display template. Where i have to put sql queries exactly ?

Offline Simple Site Designs

  • Charter Member
  • Semi-Newbie
  • *
  • Posts: 90
  • Gender: Male
    • Simple Site Designs
Re: Thank-O-Matic (Updated for SMF 2.0.4)
« Reply #2163 on: April 16, 2013, 01:27:14 AM »
Hi Skaty,

SQL/Data queries go in the source files (not the presentation templates). In the case of this one I added this:

Code: [Select]
  // Get info id of the most thanked message.
$request = $smcFunc['db_query']('', '
    SELECT ms.id_msg
    FROM {db_prefix}messages AS ms
  WHERE ms.id_topic = {int:current_topic}
    AND   ms.thank_you_post_counter > 0
    ORDER BY ms.thank_you_post_counter DESC
    LIMIT 1',
array(
'current_topic' => $topic,
)
);
if ($smcFunc['db_num_rows']($request) == 1) {
    $topicinfo['thank_you_post_most'] = $smcFunc['db_fetch_assoc']($request);
    $topicinfo['thank_you_post_most'] = $topicinfo['thank_you_post_most']['id_msg'];
  $smcFunc['db_free_result']($request);
} else {
  $topicinfo['thank_you_post_most'] = false;
  }

directly above the line (around line 250):

Code: [Select]
  // Add up unapproved replies to get real number of replies...

In the source file: Display.php

Hope that helps.

Offline Skaty

  • Jr. Member
  • **
  • Posts: 306
Re: Thank-O-Matic (Updated for SMF 2.0.4)
« Reply #2164 on: April 16, 2013, 08:28:09 AM »
Hi Skaty,

SQL/Data queries go in the source files (not the presentation templates). In the case of this one I added this:

Code: [Select]
  // Get info id of the most thanked message.
$request = $smcFunc['db_query']('', '
    SELECT ms.id_msg
    FROM {db_prefix}messages AS ms
  WHERE ms.id_topic = {int:current_topic}
    AND   ms.thank_you_post_counter > 0
    ORDER BY ms.thank_you_post_counter DESC
    LIMIT 1',
array(
'current_topic' => $topic,
)
);
if ($smcFunc['db_num_rows']($request) == 1) {
    $topicinfo['thank_you_post_most'] = $smcFunc['db_fetch_assoc']($request);
    $topicinfo['thank_you_post_most'] = $topicinfo['thank_you_post_most']['id_msg'];
  $smcFunc['db_free_result']($request);
} else {
  $topicinfo['thank_you_post_most'] = false;
  }

directly above the line (around line 250):

Code: [Select]
  // Add up unapproved replies to get real number of replies...

In the source file: Display.php

Hope that helps.

Thank you.  I added this code in display.php but i think there have to be something for display.template.com. I added the codes abode, but can't see the most thanked topic or post. There is missing something :(

  // Count up the thanks and work out if we have a winning post
  $bigthx = 0;
  foreach($context['thank_you_post'] as $thxmsgid => $thxpost) {
    if(is_numeric($thxmsgid)) {
      $thisthx = count($thxpost['fulllist']);
      if($thisthx > $bigthx) {
        $bigthx   = $thisthx;
        $bigthxid = $thxmsgid;
      }
    }
  }
  // $scripturl.'?topic='.$context['current_topic'].'msg'.$bigthxid.'#msg'.$bigthxid

Offline 4LP3RUZ1

  • SMF Hero
  • ******
  • Posts: 3,416
  • Gender: Male
  • I don't like frozen frogs :(
Re: Thank-O-Matic (Updated for SMF 2.0.4)
« Reply #2165 on: April 16, 2013, 11:03:18 AM »
I get a small bug and error logs which I have traced back to the permission system.

Heres the deal;

The error message is as follows:
Code: [Select]
http://www.****.com/index.php?action=profile
8: Undefined index: label
File: /www/toyotaclubtr.com/public_html/Themes/default/GenericMenu.template.php
Line: 180

Now this only happened with users on 0 messages, which got me thinking that it was a permission problem.

What happens is, my 0 message users DON'T have permissions to view OTHER user profiles, only their own.

If a 0 message user goes into his profile screen, the ThankOMatic menu appears ($txt['thankyoutitle']), however the subsection menu does not appear. Its empty.

If I set the permission to view other profiles to ON, then the menu appears and I get no error message in the log.

So,

The question is. How can I get rid of the error without changing the permissions? (I don't want 0 message users looking at other user profiles...)

Online emanuele

  • Developer
  • SMF Super Hero
  • *
  • Posts: 11,892
  • Gender: Male
  • Because Orange is Orange
Re: Thank-O-Matic (Updated for SMF 2.0.4)
« Reply #2166 on: April 18, 2013, 08:34:36 AM »
The version currently uploaded reports only the changes to the header of the Memberlist.template.php table and not the change needed to the table itself.

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non รจ una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline Smael

  • Newbie
  • *
  • Posts: 2
Re: Thank-O-Matic (Updated for SMF 2.0.4)
« Reply #2167 on: May 08, 2013, 06:33:25 AM »
Updater seems to fail on multiple pages. Attempted to install it manually but found that the source files are not at all sync to the instructions..

Offline Kindred

  • Support Specialist
  • SMF Master
  • *
  • Posts: 31,383
  • Gender: Male
    • wagner999 on Facebook
    • @Kindred_999 on Twitter
Re: Thank-O-Matic (Updated for SMF 2.0.4)
« Reply #2168 on: May 08, 2013, 07:34:41 AM »
That is hardly the fault of the mod...
http://wiki.simplemachines.org/smf/Error_in_mod_installation

the mod installs just fine on a default SMF install. If you have made other modifications already, then there is a chance any additional mod will not be able to auto-install and you will have to manually apply the changes
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support forums.  Thank you.

Offline Smael

  • Newbie
  • *
  • Posts: 2
Re: Thank-O-Matic (Updated for SMF 2.0.4)
« Reply #2169 on: May 08, 2013, 01:07:42 PM »
That is hardly the fault of the mod...
http://wiki.simplemachines.org/smf/Error_in_mod_installation

the mod installs just fine on a default SMF install. If you have made other modifications already, then there is a chance any additional mod will not be able to auto-install and you will have to manually apply the changes

I'm aware.

I've done attempts to install it manually however:

Code: [Select]
echo '
<span>', $poster['time_online'], '</span>
</dd>';
}

This is for example non-existant in my code.

Offline Kindred

  • Support Specialist
  • SMF Master
  • *
  • Posts: 31,383
  • Gender: Male
    • wagner999 on Facebook
    • @Kindred_999 on Twitter
Re: Thank-O-Matic (Updated for SMF 2.0.4)
« Reply #2170 on: May 08, 2013, 01:16:24 PM »
yup...   and if you have mods which have alreayd altered the target code or custom themes which used a different style of coding, then you have ot start using human intuition on where it should actually be added....
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support forums.  Thank you.