News:

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

Main Menu

Topic Ratings

Started by Oldiesmann, January 20, 2005, 01:59:43 PM

Previous topic - Next topic

evillair

Is there a way I can change this code to let me specify a different *.gif for each rating? (IE: a 1 rating = 1.gif, a 2 rating = 2.gif etc)

MessageIndex.template.php
if ($context['show_rating'])
{
echo '
<td class="windowbg" valign="middle" width="8%" align="center">';
if ($topic['rating']['empty'] == 1)
echo '';
else
{
for ($i = 0; $i < $topic['rating']['whole']; $i++)
echo '<img src="', $settings['images_url'], '/star.gif" alt="*" border="0" />';
//!!! Should have a half star!
if (!empty($topic['rating']['half']))
echo '<img src="', $settings['images_url'], '/star.gif" alt="*" border="0" />';
}
echo '
</td>';
}


I know nothing of php but I'm trying to learn  :-\
I 'think' it's this part of the code from MessageIndex.template.php that controls this.

If I can't get a rating count I'd like to try to get a different image per rating. :)


L0relei

That's quite simple. First of all, upload the images *.gif in the directory for images of your theme. For example, you can do something like that :
if ($context['show_rating'])
{
echo '
<td class="windowbg" valign="middle" width="8%" align="center">';
if ($topic['rating']['empty'] == 1)
echo '';
else
{
$totrating = $topic['rating']['whole'];
if (!empty($topic['rating']['half'])) $totrating = $totrating + 1;

if ($totrating == 0) echo '<img src="', $settings['images_url'], '/0.gif" alt="*" border="0" />';
if ($totrating == 1) echo '<img src="', $settings['images_url'], '/1.gif" alt="*" border="0" />';
if ($totrating == 2) echo '<img src="', $settings['images_url'], '/2.gif" alt="*" border="0" />';
if ($totrating == 3) echo '<img src="', $settings['images_url'], '/3.gif" alt="*" border="0" />';
if ($totrating == 4) echo '<img src="', $settings['images_url'], '/4.gif" alt="*" border="0" />';
if ($totrating == 5) echo '<img src="', $settings['images_url'], '/5.gif" alt="*" border="0" />';

}
echo '
</td>';
}
Just Lo` It

evillair


ghostfreak

A vote for a RC2 version as well :)

http://www.xfilesforum.net - Dare To Believe?
http://www.idealforum.co.uk - The Green Blitz!

RockTheRoad

Another vote for RC2 version...  8)

evolus


Gobo

i am voting on behalf of 5 people

so 5 more votes :D (for RC2)

lol

evillair

#107
I can't get this to install with a clean install of 1.0.6, anyone else has this issue?

I tried installing both versions...
The 1.02 version gives me an error with the Display.php file.
The 1.03 version won't install, I get this error - The package you are trying to download or install is either corrupt or not compatible with this version of SMF.

[fixed] I manualy configured the Display.php file. Had a hard time since the code was different and the search/replace wasn't a help. Works though.


Teme

Oh.. people are voting for RC2 version. I want to see it working at RC2 too.

Teme

TANDIONO.COM

SMF Version: SMF 1.0.6
I get Display.php and ManageBoards.php fail when try to install topic rating mods.

1. Execute Code RatingsPdb.php 
2. Execute Modification ./Sources/Display.php Failure
3. Execute Modification ./Sources/Load.php Success
4. Execute Modification ./Sources/ManageBoards.php Failure
5. Execute Modification ./Sources/ManageMembers.php Success
6. Execute Modification ./Sources/MessageIndex.php Success
7. Execute Modification ./Sources/RemoveTopic.php Success
8. Execute Modification ./Themes/default/Display.template.php Success
9. Execute Modification ./Themes/default/ManageBoards.template.php Success
10. Execute Modification ./Themes/default/MessageIndex.template.php Success
11. Execute Modification ./Themes/default/languages/Modifications.english.php Success


Is there anyway that i can do? Thanks

SleePy

RC2 VERSION:
Ok. I got permission from Oldiesmann to update his mod. He is kinda busy right now and doesn't have the time to update his mods.

Now. Sadly to say the only thing i haven't worked into the RC2 update of this is half stars... for one smf by default doesn't have half stars and two the code Oldiesmann was using wasn't working at all doing half stars. Those that want to look at the code for me and see what we can do to fix it and make it work i would gladly appreciate it.

Im calling this a beta because i only tested it on my test site on my local computer and webserver. So i do not know what problems you guys will experience. So if you got test sites go ahead and try it out and see what problems you get.
http://lordsofclantribe.com/SleePys/Topic_Rating_RC2_beta.tar.gz

Remember you need to go to Boards -> [A Board Name] Modify -> and add a check mark next to "Enable Ratings on this Board"
You then should see the mod working in that board.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Webrunner

SleePY, you're a hero!  :D
There is a difference between knowing the path and walking the path.

=========================================
Vrouwen Power! | Sprintweb: No nonsense e-Business consultancy

Webrunner

Something going wrong in Subs-Boards ...

   Type     Actie     Omschrijving
1.    Voer code uit    RatingsPdb.php    
2.    Voer aanpassing uit    .Sources/Display.php    Succes
3.    Voer aanpassing uit    .Sources/Load.php    Succes
4.    Voer aanpassing uit    .Sources/ManageBoards.php    Succes
5.    Voer aanpassing uit    .Sources/Subs-Boards.php    Test mislukt
6.    Voer aanpassing uit    .Sources/Subs-Members.php    Succes
7.    Voer aanpassing uit    .Sources/MessageIndex.php    Succes
8.    Voer aanpassing uit    .Sources/RemoveTopic.php    Succes
9.    Voer aanpassing uit    .Themes/default/Display.template.php    Succes
10.    Voer aanpassing uit    .Themes/default/ManageBoards.template.php    Succes
11.    Voer aanpassing uit    .Themes/default/MessageIndex.template.php    Succes
12.    Voer aanpassing uit    .Themes/default/languages/Modifications.english.php    Succes
There is a difference between knowing the path and walking the path.

=========================================
Vrouwen Power! | Sprintweb: No nonsense e-Business consultancy

SleePy

#113
ok give it a try now
http://lordsofclantribe.com/SleePys/Topic_Rating_RC2_beta2.tar.gz
Use the old version to uninstall it and this version to install. since its a beta im not trying to work on making it work between them. if you don't want to lose any current ratings you need to uncompress this and take out the Ratingsdb.php file. then compress it again and upload to your site and it should be fine.

Also i need to let you guys know a few bugs that are happening that im working on trying to find out why and how to fix.
1. Some Reason on my offical site were i installed it to test it i can't add it to the modify boards. Some reason its not being saved into the mysql database. but my test sites which are fresh installs of rc2 all work fine.. no clue why on one they do and the other do not.
- Topic_Rating_RC2_beta2 Fixes this issue. It was just a simple little typo on my part of making it work with rc2.

2. if a Topic Rating is given a 5 (the highest) the MessageIndex (Page that shows all the topics for a board) shows N/A instead of 5 stars. Must be something in Oldiesmann's coding as i never changed anything to do that for 5 stars.
- Was able to fix this. Allot of code was changed on how it is read and saved to fix this though.
--Edit--
I fixed problem 1. now onto problem 2. This also fixes a bug were there was undefined indexes going though the error log
Edit2: redownload the 2b to fix problem 2. i also fixed some mini bugs i found.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Gary

The thing installed perfectly,

Quote
1.     Execute Code     RatingsPdb.php     
2.    Execute Modification    ./Sources/Display.php    Test successful
3.    Execute Modification    ./Sources/Load.php    Test successful
4.    Execute Modification    ./Sources/ManageBoards.php    Test successful
5.    Execute Modification    ./Sources/Subs-Boards.php    Test successful
6.    Execute Modification    ./Sources/Subs-Members.php    Test successful
7.    Execute Modification    ./Sources/MessageIndex.php    Test successful
8.    Execute Modification    ./Sources/RemoveTopic.php    Test successful
9.    Execute Modification    ./Themes/default/Display.template.php    Test successful
10.    Execute Modification    ./Themes/default/ManageBoards.template.php    Test successful
11.    Execute Modification    ./Themes/default/MessageIndex.template.php    Test successful
12.    Execute Modification    ./Themes/default/languages/Modifications.english.php    Test successful

But I'm not seeing

Remember you need to go to Boards -> [A Board Name] Modify -> and add a check mark next to "Enable Ratings on this Board"
Gary M. Gadsdon
Do NOT PM me unless I say so
War of the Simpsons
Bongo Comics Fan Forum
Youtube Let's Plays

^ YT is changing monetisation policy, help reach 1000 sub threshold.

SleePy

if you do not use the default theme you will need to either make the changes that this mod does to the default theme.
I worked with the default theme while making this for rc2 so if you are using anything other it will have to be hand coded in. i haven't worked out classic or Babylon yet. im still working out the bugs from the update.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Gary

#116
I was using the Default while doing it.

EDIT: Silly me. I must have clicked on another item on the final stage of installation. So it didnt install after all. <slaps forehead>

Except now I get;

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /****/****/****/****/Sources/MessageIndex.php on line 630

When viewing a board.
Gary M. Gadsdon
Do NOT PM me unless I say so
War of the Simpsons
Bongo Comics Fan Forum
Youtube Let's Plays

^ YT is changing monetisation policy, help reach 1000 sub threshold.

SleePy

thought i fixed that...
anways:

Edit: Sources/MesssageIndex.php
Find:
'views' => $row['numViews']
Replace:
'views' => $row['numViews'],

I missed a comma at one time while adding it to the topic array and thought i fixed it in the package.. it is showing fixed... hmmm
http://lordsofclantribe.com/SleePys/Topic_Rating_RC2_beta2c.tar.gz
try that one and it should work. Also it fixed a a bug of another undefined index that just found today.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Gary

Gary M. Gadsdon
Do NOT PM me unless I say so
War of the Simpsons
Bongo Comics Fan Forum
Youtube Let's Plays

^ YT is changing monetisation policy, help reach 1000 sub threshold.

SleePy

srry i did that before going to bed and made the post before i uploaded it... my ftp program crashed and didn't upload it. it is there now.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Advertisement: