Different Ratings Block Based on Category

95 views
Skip to first unread message

NativeBiz

unread,
May 4, 2011, 3:15:32 PM5/4/11
to gd-star-rating
I have integrated gd-star-ratings into my posts pages but want to
display different rating block instances based on the category.

Example:

Custom Form 1 - Cat ID 6 - show rating block (ID2)
Custom Form 2 - Cat ID 7 - show rating block (ID3)
Custom Form 3 - Cat ID 8 - show rating block (ID4)
Custom Form 4 - Cat ID 9 - show rating block (ID5)

Since I have added the star ratings to comments, I need to add an (if)
argument to my comments template so that each post will show their
respective rating block based on category id.

I know where this should be placed, just not sure on how to write the
argument. Here is how a single instance is called to show rating block
in comments:

So basically, I need to write an argument to show ratings blocks based
on post category.

If category 6 show rating block (2)
If category 7 show rating block (3)
If category 8 show rating block (4)
If category 9 show rating block (5)

else show rating block (1)

Thanks for any help.

NativeBiz

unread,
May 10, 2011, 6:22:39 PM5/10/11
to gd-star-rating
UPDATE:

By simply duplicating the following in comments.php and changing the
rating block id from 2 to 3 I'm now able to show a different multi
rating/voting block based on category:

<code> <?php if (in_category('9') &&
defined("STARRATING_INSTALLED")) : ?>
<p><?php wp_gdsr_comment_integrate_multi_rating(2); ?>
<label for="url"><small>Rating</small></label>
</p><?php endif; ?></code>

<code> <?php if (in_category('18') &&
defined("STARRATING_INSTALLED")) : ?>
<p><?php wp_gdsr_comment_integrate_multi_rating(3); ?>
<label for="url"><small>Rating</small></label>
</p><?php endif; ?></code>

Not sure if it's okay to do this way WITHOUT using (if else) but it
seems to be working.

====================
ISSUE:
====================

Trying to display different multi 'results' blocks based on category
(template_functions.php)

Copied the following like I did above for comments.php

<code> <?php if (in_category('9') &&
defined("STARRATING_INSTALLED")) : ?>
<div style="float: right">
<?php wp_gdsr_comment_integrate_multi_result(get_comment_ID(), 2, 51,
"crystal", 16); ?>
</div>
<?php endif; comment_text(); ?>
<?php wp_gdsr_render_comment_thumbs(26); ?></code>

<code> <?php if (in_category('18') &&
defined("STARRATING_INSTALLED")) : ?>
<div style="float: right">
<?php wp_gdsr_comment_integrate_multi_result(get_comment_ID(), 3, 51,
"crystal", 16); ?>
</div>
<?php endif; comment_text(); ?>
<?php wp_gdsr_render_comment_thumbs(26); ?></code>

This way does display correct blocks based on category, BUT the
comment is being shown twice.

I'm guessing a simple cut and paste and change cat and block ID won't
work here, probably needs the if else.

I'm getting close to making this work and would really appreciate any
help in setting this up correctly.

Thanks.
Reply all
Reply to author
Forward
0 new messages