jRating disables per theme block assignments

bittindm - March 8, 2007 - 02:34
Project:jRating
Version:5.x-1.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

We running Drupal 5.1 and have multiple subthemes being applied to different sections of our site. Each subtheme has a distinct set of blocks assigned to it. Some blocks are shared between sections however we had to go in to each theme individually and assign the blocks to the proper positions. After enabling jRating, none of the block assignments where accessible on the Blocks page using the Theme tabs. Only the default theme was able to receive block assignments which then didn't carry over to any of the subthemes. After disabling jRating, things went back to normal and the original block assignments were applied correctly.

Similar to the issue being detailed in this post for a different module, http://drupal.org/node/59702 Maybe a factor in the admin theme issue for jRating?

#1

extrabigmehdi - June 5, 2007 - 14:40
Version:5.x-1.x-dev» 5.x-1.0
Status:active» needs review

hi
I got the same problem with the official version (i.e not dev).
and I don't understand why such important bug was not fixed yet.
Anyway, I found a quite easy fix:

near line 38 of file jrating.module,
replace the following code:

drupal_add_js('function rating_postsubmit(nid){' . theme('jrating_postsubmit') . '}', 'inline');

by this one:

drupal_add_js('function rating_postsubmit(nid){ return true; }', 'inline');

Seems that the call of the function "theme" is unnecessary here, and is inducing the problem.

#2

hickory - June 5, 2007 - 15:22
Status:needs review» needs work

The use of theme is necessary here, as it allows you to set the action that should be called in javascript after the vote is made.

What I don't understand is why this is interfering with other theme functions.

(It hasn't been fixed yet because I'm not using multiple themes, so haven't got this problem).

Perhaps this could be made configurable by including a javascript file from the theme folder instead...

#3

extrabigmehdi - June 6, 2007 - 12:33

hi hickory,

The use of theme is necessary here, as it allows you to set the action that should be called in javascript after the vote is made.

If I'm not wrong , the function theme_jrating_postsubmit always return true by default. I looked trough all the code of jrating , searching for the string "jrating_postsubmit" , and found nowhere a code that modify such behavior.
Also, It seems to work, so I don't know what dysfunctions my fix introduce.

It hasn't been fixed yet because I'm not using multiple themes, so haven't got this problem

Well, I like to use at least two different themes one for frontend, and one for backend. I think that's important to make a clear distinction, especially, if you begin to use drupal.

What I don't understand is why this is interfering with other theme functions.

I just began to use drupal, and I'm not very familiar with API. However , according to this thread my guess is that the problem comes from the call of the init_theme function by the theme function itself. Perhaps , you should take a look at the actual implementation of the theme function here

#4

hickory - June 6, 2007 - 12:35

If I'm not wrong , the function theme_jrating_postsubmit always return true by default. I looked trough all the code of jrating , searching for the string "jrating_postsubmit" , and found nowhere a code that modify such behavior.

It's a themeable function, so you can override it in your theme file to change the action that happens after a vote is placed.

#5

mikesmullin - August 18, 2007 - 21:10

I'm experiencing the same problem. I confirm the patch from #1 works for me.

#6

pippi - September 12, 2007 - 07:37

same problem......

#7

sanduhrs - October 19, 2007 - 12:10

Another workaround would be to _not_ add the JavaScript on admin pages.

<?php
   
if (arg(0) != 'admin') {
     
drupal_add_js('function rating_postsubmit(nid){' . theme('jrating_postsubmit') . '}', 'inline');
    }
?>

#8

hickory - November 21, 2007 - 17:15

The explanation for this is in http://drupal.org/node/64409#comment-408346 - I'll have to move the theme function out of hook_menu or hook_init.

#9

hickory - November 21, 2007 - 17:28
Status:needs work» fixed

Removed the theme function call. jrating_postsubmit can now be defined in a javascript file included by an individual theme or module.

#10

Anonymous - December 5, 2007 - 17:31
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.