News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Post Ratings

Started by SoLoGHoST, October 27, 2009, 11:54:09 AM

Previous topic - Next topic

twotonetwo

Hi im trying to chnage the word "enabled and disabled" in the post for an image, but i cant find it in teh language files using teh parser. can you tell me how i can change the words "enabled" and "disabled" into images, or rather where i can find the text so i can change it for an image instead please? Thank you!!



Greta mod btw having alot of fun with this one  ;D
SMF 2.0 RC3  |  Tiny Portal 1.0 Beta 5.1

jani01

really a great mod.  already paid thanks also count my thanks too.

cheers


:)


SoLoGHoST

#262
Quote from: twotonetwo on May 11, 2010, 05:41:14 AM
Hi im trying to chnage the word "enabled and disabled" in the post for an image, but i cant find it in teh language files using teh parser. can you tell me how i can change the words "enabled" and "disabled" into images, or rather where i can find the text so i can change it for an image instead please? Thank you!!



Greta mod btw having alot of fun with this one  ;D

If you are using any other theme besides Core or Curve and you didn't select to install into other themes upon installation of this mod, than you will have to follow the 5 step process on adding in the images located where you download the mod:  Post Ratings Mod.  After you get the images to show, than you can simply open up Display.template.php and the bit of code that you would be interested in is located within here:

<li class="', $message['ratings_enabled'] ? 'enable_ratings_button' : 'disable_ratings_button', '"><a href="', $scripturl, '?action=postratings;sa=', ($message['ratings_enabled'] ? 'disable' : 'enable'), ';topic=', $context['current_topic'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', $message['ratings_enabled'] ? $txt['enable_ratings_post_alt'] : $txt['disable_ratings_post_alt'], '">', ($message['ratings_enabled'] ? $txt['enable_ratings_post'] : $txt['disable_ratings_post']), '</a></li>';

The $txt['enable_ratings_post'] and $txt['disable_ratings_post'] is the actual text for this ("Enabled", and "Disabled").  You should be able to figure out how to change it if you want.

If you don't want the image that gets put in here, than you'll have to edit this whole thing so that it can link to a css class where the images are defined, but don't mess with the <a> tags href attribute or there will be problems.

Cheers :)


twotonetwo

SMF 2.0 RC3  |  Tiny Portal 1.0 Beta 5.1

Xarcell

Quote from: MATTEK on April 20, 2010, 07:44:06 PM
I can't seem to get this one to work. I've checked all settings and made sure my member groups have the correct permissions. Still...no option anywhere to rate a post. I'me using Curve default as my theme.

you can't rate your own topics...  :D

giveaway365.com

There seems to be some confusion.
I want to enable all topics ratings (old & New). 
These are my settings:
Automatic Ratings Setting for Topics -  All topics enabled.
Enable First Post Rating - checked


Problem is that by default I have topics disabled. I have to manually enable each one of the new/old topics. I have done the file cache in routine maintanance.

Please advise what to do?

SoLoGHoST

#266
Just so people don't think I'm talking to myself here, as I thought for a sec...lol, but than realized that the user must've deleted the post, so for whatever reason, I won't mention the username....
Quote
There seems to be some confusion.
I want to enable all topics ratings (old & New).
These are my settings:
Automatic Ratings Setting for Topics -  All topics enabled.
Enable First Post Rating - checked


Problem is that by default I have topics disabled. I have to manually enable each one of the new/old topics. I have done the file cache in routine maintanance.

Please advise what to do?
Make sure you have Post Ratings enabled as well.

And to be sure, because I placed a check in here to check in $modSettings if it was already selected to not do it again, since this could take some time to perform this, and people may not think to change the setting from All Topics enabled to a different setting.  So here's what you do...

1. Make sure you have Post Ratings enabled (very first option in the settings).
2. Change "Automatic Ratings Setting for Topics" to New Topics enabled
3. Click on the SAVE Button at the bottom.

Now after it saves, change "Automatic Ratings Setting for Topics" to All topics enabled and Click the SAVE Button.

Let me know how that goes for you.

P.S. -> And don't forget about the Permissions for Post Ratings.

dmacleo

first, on smf 2 rc3 it works reat, thank you.

I would like to know how to move the post rating options/rate this post bar further up on the post itself. top right would be awesome but really anything to move up a bit would be nice.

I think this is not really a mod question but probably some template.css edit needed, I was hoping you could just point me where to look so I can learn.

thanks for the cool mod :)

SoLoGHoST

Look in Display.template.php, this is where all of the code gets put for displaying Post Ratings when viewing topics.  Let me know if you require more info on this.

Cheers :)

dmacleo

I will look at that later today and play around with it, thanks very much :)

dmacleo

#270
LOL  I got no idea what to do there.
I think its in this area. possibly in the section I bolded and underlined?

Quote// Post Ratings BEGIN...
      //

      // Inner Style?
      if(empty($modSettings['post_ratings_layout_style']))
      {
         // is it enabled or not??
         if ($message['ratings_enabled'] && $message['topic_enabled'] && $message['first_enabled'] && allowedTo('postratings_view'))         
         {
            echo '<table class="inner" style="border-top: none;" cellpadding="0" cellspacing="0" width="100%"><tr><td align="left" valign="top" style="white-space: nowrap;">';
            
            // does the post have any ratings yet?
            if (!$message['has_ratings'])
            {
                  echo parse_bbc($modSettings['post_ratings_not_rated']);
            }
            else
            {
               $textOut = 'post_ratings_text' . $message['post_rating_num'];
               
               echo $message['post_rating_stars'] . '</td>
               <td align="left" valign="middle" width="100%"><div> ' . parse_bbc($modSettings[$textOut], true) . '</div>';
               
               if (!empty($modSettings['post_ratings_show_quantity']))
                  if (!empty($message['post_rating_totals']))
               echo '</td><td class="smalltext" align="right" valign="middle" style="white-space: nowrap;">' . $txt['postratings_count1'] . ' <strong>' . $message['post_rating_totals'] . '</strong> ' . ($message['post_rating_totals'] < 2 ? $txt['postratings_count2'] : $txt['postratings_count3']);
            }   
            echo '</td></tr></table>';
         }
      }         
      //
      // Post Ratings END!


SoLoGHoST

#271
No, that is where the rating for the post gets shown.  If I understood you right, you want to change the position of where the user rates a post within the post itself right??

Is so, you want this bit of code:
if (!$context['is_ratings_locked'])
{
if ($message['can_postratings_rate'] || !empty($message['rating']) && !$user_info['is_guest'])
{
$is_enabled = $message['ratings_enabled'] && $message['topic_enabled'] && $message['first_enabled'] ? true : false;

// Is it the POST CREATOR
if ($is_enabled && $message['not_your_post'])
{
// only show it if we need it for anything...
if (($message['can_postratings_rate'] && !$message['reached_ratings_limit']) || $message['rating']['can_postratings_edit'] || $message['rating']['can_delete_own_rating'])
{
$can_delete_only = false;


echo '<div style="clear: both;">
<script language="JavaScript" type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/postRatingsRC23.js"></script>';

$rating_nonrated_img = $boardurl . '/' . $modSettings['post_ratings_image_nonrated'];
$rating_rated_img = $boardurl . '/' . $modSettings['post_ratings_image_rated'];
$is_collapsed = empty($modSettings['post_ratings_auto_expanded']) || ($modSettings['post_ratings_auto_expanded'] == 2 && !empty($message['rating']['already_rated'])) ? true : false;

$ratingOpt = $message['can_postratings_rate'] && empty($message['rating']['already_rated']) ? parse_bbc($modSettings['post_ratings_not_expanded_rate'], true) : parse_bbc($modSettings['post_ratings_not_expanded_edit'], true);

// echo the right text link for them to click on
echo '<div onClick="javascript:doExpandCollapse(\''.$message['id'].'\', \''.$settings['images_url'].'\');" style="cursor:pointer; padding-bottom: 5px;"><span><img id="img' . $message['id'] . '" src="' . $settings['images_url'] . '/' . (!$is_collapsed ? 'collapse' : 'expand') . '.gif" /> ' . $ratingOpt . '</span></div>
<div id="pr' . $message['id'] . '"' . (!$is_collapsed ? ' class="expanded"' : ' style="display: none;"') . '>';

echo '<table cellpadding="0" cellspacing="0" border="0"><tr><td align="left" valign="middle" style="white-space: nowrap; align: left; padding: 5px 0px 5px 5px;">', !empty($message['rating']['already_rated']) ? $txt['postratings_your_rating'] : $txt['postratings_rate_it'], '</td><td align="left" valign="middle" style="white-space: nowrap; align: left; padding: 5px 5px 5px 0px;">';

$da_rating = !empty($message['rating']['your_rating']) ? $message['rating']['your_rating'] : 0;

// able to rate and/or edit ratings...
if ((($message['can_postratings_rate'] && !$message['reached_ratings_limit']) && empty($message['rating']['already_rated'])) || $message['rating']['can_postratings_edit'])
{
// Rate this post, or EDIT your Rating
for($i = 1; $i <= 5;$i++) {

$combo[$i-1] = 'img' . $message['id'];

echo '<input type="image" name="rating" id="' . $combo[$i-1] . '' . $i . '" src="'. $rating_nonrated_img . '" value="' . $i . '" border="0" onMouseOver="submitVote(\''.$message['id'].'\', \''. $i .'\'); doMover(\''. $rating_rated_img . '\', \''. $rating_nonrated_img . '\', \''. $da_rating .'\', \'' . $combo[$i-1] . '\',\'' . $i . '\'); textOutput(\''. $message['id'] . '\', \''. $i .'\');" onMouseout="doMout(\''. $rating_rated_img . '\', \''. $rating_nonrated_img . '\', \'' . $da_rating . '\', \'' . $message['id'] . '\'); textOutput(\''. $message['id'] . '\', \''. $da_rating . '\');" onClick="doSubmit(\'rate\', \''.$message['id'].'\', \''.$scripturl.'\', \''.$context['session_var'].'\', \''.$context['session_id'].'\');" style="border: none; background: transparent;" />';

// input is hidden, but necessary so we can get the ratings from the user...
echo '<input type="radio" id="rat'. $message['id'] . $i . '" name="rating" value="' . $i . '" style="display: none;" />';
}


// ok, now let's do the other hidden <input> tags...
echo
'
<input type="hidden" name="pr_messageid' . $message['id'] . '" value="' . $message['id'] . '" />
<input type="hidden" name="pr_topicid' . $message['id'] . '" value="' . $message['topic_id'] . '" />';
}
elseif ((!$message['can_postratings_rate'] && !$message['rating']['can_postratings_edit']) || $message['rating']['can_delete_own_rating'] || (!empty($message['rating']['already_rated']) && $message['can_postratings_rate']))
{
// do you have any rating to delete?
if (!empty($message['rating']['your_rating']))
{
$can_delete_only = true;

for($i=0; $i < 5; $i++) {
if ($i < $message['rating']['your_rating'])
echo '<img src="', $rating_rated_img, '" alt="*" border="0" />';
else
echo '<img src="', $rating_nonrated_img, '" alt="*" border="0" />';
}

echo '</td><td align="left" width="100%" valign="middle" style="align: left; padding: 5px;"><div id="dRate' . $message['id'] . '" style="position: relative; left: 0px;"></div></td>';
echo '
<script language="JavaScript" type="text/javascript">
setInnerHTML(document.getElementById("dRate"+' . $message['id'] . '), "' . addslashes(parse_bbc($modSettings['post_ratings_text' . $da_rating], true)) . '");
</script>';
}
}

if (!$can_delete_only)
{
echo '</td><td align="left" width="100%" valign="middle" style="align: left; padding: 5px;"><div id="dRate' . $message['id'] . '" style="position: relative; left: 0px;"></div></td>';

if (!empty($message['rating']['your_rating']))
echo '
<script language="JavaScript" type="text/javascript">
alreadyRated(\'' . $rating_rated_img . '\', \'' . $rating_nonrated_img . '\', \'' . $message['id'] . '\', \'' . $message['rating']['your_rating'] . '\');
setInnerHTML(document.getElementById("dRate"+' . $message['id'] . '), "' . addslashes(parse_bbc($modSettings['post_ratings_text' . $message['rating']['your_rating']], true)) . '");
</script>';
}

if (!empty($message['rating']))
if ($message['rating']['can_delete_own_rating'] && !$message['reached_ratings_limit'])
{
echo '<td align="right" valign="middle" style="white-space: nowrap; padding-right: 5px;">

<a href="javascript:void(0);" onClick="doSubmit(\'delete\', \''.$message['id'].'\', \''.$scripturl.'\', \''.$context['session_var'].'\', \''.$context['session_id'].'\');">' . $txt['remove_rating'] . '</a>
<input type="hidden" name="pr_del' . $message['id'] . '" value="' . $message['id'] . '">

</td>';

}

echo '
</tr></table></div></div>';
}
}
}
}



Ofcourse, if you don't know what you're doing, it would be better for me to do it for you, though honestly I'm a bit too busy with a different project at the moment.  If you have a test site, test it on there.  The code above is the entire code for rating a post, so it's basically the entire code above, would just get moved to a different area of the template.

Good Luck :)

dmacleo

what I would like to TRY (key word :) ) to do is move the  Post Rating Options (Rate this post) (rate1 attachment) up to the top of the post section possibly above the post options (rate 2) area to remove the excess space that each post takes up on a page.
does that make sense?

I will try out that code in a bit, thanks.

SoLoGHoST

#273
Yeah, so the code I posted is the code you will need to search for and move the entire code up further in the template, above where those buttons are defined and outputted within the template.

EDIT:
Though, like I said, it would be better for me to do it for you.  Or maybe someone else could.

Perhaps if you post up your Display.template.php file, either myself, or someone else here could do it for you.

Cheers :)

dmacleo

sorry it took so long to respond, I did not get a chance to try that out yet
I could post mine if you would not mind.
then I could look at the differences and learn from it.
I thank you for the help.

SoLoGHoST

#275
Ok, so just to be clear here on where you want it.  Do you want it above the 2nd pic that you attached?  Or below it?  Or what exactly...

I mean do you want it at the very top above everything, even the Post Subject Title itself?

Cheers :)

SoLoGHoST

Well, here it is above everything.  I haven't tested it out, so it would be wise to test first...

The lines of code are from Lines #566 To 671.  I left a little gap up top and to the bottom so you can see this.  I believe I got it in between the right <div> tags, but if not than you can play with it to get it just right for the way you want it than.

Cheers :)

dmacleo

I wlil try that in a few moments, thanks so very much.

rd

#278
This is pretty good, I use it here: http://duke.xadro.net


dmacleo

#279
ok it has changed the position to top of post but the top of the whole post is now at bottom edge of the user profile section.
very odd, LOL
the positions are right where they need to be as far as the mod, its how the user info seems to affect everything that is the issue.
I wonder, and I am bad at this, if it is a div tag issue. I will experiment with it, thanks so much for the help.

Advertisement: