Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-01-10 16:36:25

joel
Member
Registered: 2004-11-26
Posts: 162

Questions about tcm_rating

I´ve just installed the tcm_rating plug-in and wanted to modify this plug-in a little bit. There are three things I would like (but I dont know how):

1. Get rid of the Submit-button. (submit onchange)
2. Use a select-dropdown instead of the radio-buttons.
3. Output the average besides the star-images something like this: * * * * * (4,8)

Could anyone help me on this?

Thanks!

Offline

#2 2005-01-10 19:56:12

paularms
Member
From: University of Minnesota
Registered: 2004-10-21
Posts: 155
Website

Re: Questions about tcm_rating

joel: I can help you later tonight. If you are comfortable editing the PHP yourself, you can just check out the ratings on the photos in my archives

Offline

#3 2005-01-11 02:27:38

joel
Member
Registered: 2004-11-26
Posts: 162

Re: Questions about tcm_rating

paularms:
I would just love to be able to change the plug-in into something like yours.
I´m not very good with php, so I would gladly appreciate some assistance over here :)

Offline

#4 2005-01-11 03:12:10

paularms
Member
From: University of Minnesota
Registered: 2004-10-21
Posts: 155
Website

Re: Questions about tcm_rating

alright i wrote up some instructions on how to make it just like mine. Changing things to a dropdown wouldn’t be that complicated. Just edit the ratings_input to output options instead of input type=“radio” and delete the images off from where I put all that code.

Offline

#5 2005-01-11 12:56:10

joel
Member
Registered: 2004-11-26
Posts: 162

Re: Questions about tcm_rating

Thanks for the article :) I have a small question though.

When I look at the source-code i notice the following:

<code><form name=“ratingform action=”/textpattern/ratings.php” method=“post”></code>

one “ is missing after the “name”. Is that the reason why this thing won´t fly?

The php-code looks like this:

<code>$data = “Rate this photo:</p>\n<form name=\“ratingform\” action=\”“.$path_from_root.“textpattern/ratings.php\” method=\“post\”>\n”;</code>

Last edited by joel (2005-01-11 12:57:27)

Offline

#6 2005-01-11 15:33:53

paularms
Member
From: University of Minnesota
Registered: 2004-10-21
Posts: 155
Website

Re: Questions about tcm_rating

It should be returning another quote after name=“ratingform” because \” returns a double-quote. It is also returning it on my installation.

Offline

#7 2005-01-11 16:56:35

joel
Member
Registered: 2004-11-26
Posts: 162

Re: Questions about tcm_rating

I see… here is the full code for “ratinginput”

<code>
function tcm_ratinginput($atts)
{ if (is_array($atts)) extract($atts);

global $pretext; extract($pretext);

global $thisarticle; $id = $thisarticle[‘thisid’];

$ip= @getHostByAddr($_SERVER[‘REMOTE_ADDR’]); $previous = safe_field(“posted”, “txp_tcm_ratings”, “ip = ‘$ip’ AND parentid = ‘$id’ ORDER BY posted DESC”);

$data = “Rate this photo:</p>\n<form name=\“ratingform\” action=\”“.$path_from_root.“textpattern/ratings.php\” method=\“post\”>\n”; $data .= “\t<input type=\“hidden\” name=\“id\” value=\”$id\” />\n”; if(!$range) { $range = 5; } for($i = 1;$i <= $range;$i++) { $data .= “\t<input type=\“radio\” name=\“rating\” value=\”$i\” onclick=\“submitform();\” /><img src=\”/images/”.$i.“star.jpg\” alt=\”$i Star\” border=\“0\” class=\“no\” />\n”; } if(!$previous){ $data .= “</form>\n\t<p>You will only be able to vote once, so choose wisely.</p>\n”; }elseif($previous) { $data = “\tYou have already rated this photo.</p>”; }else{ $data = $data.‘You have already rated this photo.</p>’; } return $data .=”\n”;
}
</code>

I´ve been staring at this for some time now I can tell ;)

Offline

#8 2005-01-11 18:10:45

paularms
Member
From: University of Minnesota
Registered: 2004-10-21
Posts: 155
Website

Re: Questions about tcm_rating

so is it working for you or not?

Offline

#9 2005-01-11 19:26:32

joel
Member
Registered: 2004-11-26
Posts: 162

Re: Questions about tcm_rating

no not really.
I click on the radio-button but nothing happends.
The script still outputs this: <code><form name=“ratingform action=”/textpattern/ratings.php” method=“post”></code> with the double-quote missing.

Do you think this may be the problem?

Offline

#10 2005-01-11 21:04:27

paularms
Member
From: University of Minnesota
Registered: 2004-10-21
Posts: 155
Website

Re: Questions about tcm_rating

yes, that is the problem. I’m not sure why it isn’t outputting the closing double quote on name=“ratingform”. I don’t know what to tell you other than try replacing the code for rating_input again.

Offline

#11 2005-01-11 21:04:57

paularms
Member
From: University of Minnesota
Registered: 2004-10-21
Posts: 155
Website

Re: Questions about tcm_rating

Also, make sure that you put the javascript on the page that you have the rating form on.

Offline

#12 2005-01-11 21:55:43

joel
Member
Registered: 2004-11-26
Posts: 162

Re: Questions about tcm_rating

Right now I have the javascript placed in the “rating-form”. Perhaps it might be better to place it on the actual “page”. Let me play around for a while and I´ll get back to you with a status-report :)

Offline

Board footer

Powered by FluxBB