Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hey!
Would be cool if I could add a title attribute via the rate configuration.
Thanks
Yannick
Comment | File | Size | Author |
---|---|---|---|
#13 | rate-theming-940532.patch | 10.89 KB | ymakux |
#5 | rate.module.patch | 348 bytes | foxfabi |
Comments
Comment #1
walker2238 CreditAttribution: walker2238 commentedYou can, just put theme_rate_button() into your template.php file and add the title. Use $text which will display the labels.
Comment #2
josh@pixael.com CreditAttribution: josh@pixael.com commentedi think the meaning of the question was different... i had to insert the title above each fivestar widget
i found a "quick" solution changing the theme_rate_button function
it's very strange that the title is not printed by default because with more widget is different to understand what an user is voting...
this is my snippet
Comment #3
dreamdust CreditAttribution: dreamdust commentedDisplaying a title is a theme issue, so I'm changing this issue category to "support request."
In response to j0sh's comment, I have to disagree that the lack of a default widget title is strange. The majority of rating widgets on the web do not have a title (youtube for example).
Comment #4
dreamdust CreditAttribution: dreamdust commentedAlso, it looks like both j0sh and walker2238 have good solutions for this, so let's mark it "closed (fixed)."
Comment #5
foxfabi CreditAttribution: foxfabi commentedi have multiple voting options for node and views. also of the same type.
so i need to display the title of the widget in views and nodes.
could an option field be usefull: display title?
my patch, please review. may not be complete.
Comment #6
kvguser CreditAttribution: kvguser commented#2 works perfectly, #5 - not at all (at least for me)
Comment #7
zazinteractive CreditAttribution: zazinteractive commented#2 didn't work for me. It would only display a title on the first widget of the page.
Comment #8
IRoar CreditAttribution: IRoar commentedHi. I agree with j0sh that it seems strange that this module doesn't support widget titles. I understand dreamdust's point that sites like youtube don't have titles displayed above their voting widget, but youtube doesn't rate each video on multiple criteria, where as this module does allow that. Anyways, that is not really important. I am posting to request a little help. I am not a coder, but I have muddled my way through pasting code and testing and retesting until I get things to work, but I am working on a site that I would like to do properly. So, I am wondering if someone could hold my hand through implementing j0sh's solution, because I think that is what I am looking to do (have a criterion listed above each 5 star rating option).
My problems are:
1) I don't know where exactly to paste the snippet that j0sh posted.
2)When this snippet is pasted, just to be clear, I am assuming that it doesn't require any deleting of the original module code.
That is all. Great module, thanks very much for the work!
Comment #9
IRoar CreditAttribution: IRoar commentedDrat, just noticed that this is a Drupal 6 fix, but I am using Drupal 7 so I guess you can ignore my previous post.
Comment #10
oxigen CreditAttribution: oxigen commentedNone of the tricks above worked for me so I made my solution which is actually working!
Hope it helps for others...
Cheers.
Comment #11
bassem CreditAttribution: bassem commentedany solutions for the rate widget title for drupal 7?
Comment #12
geert CreditAttribution: geert commentedThis is what I did for the 7 version, in rate.module, line 325
Basically, I added
in front of the theme part
It provides a workaround as It displays the "admin" title, where I am looking for a user-focused title
Comment #13
ymakux CreditAttribution: ymakux commentedhttp://drupal.org/node/1891422
d7
Comment #14
therobyouknow CreditAttribution: therobyouknow commentedTo the patch maker (primarily or other folks please comment too):
I presume this patch enables us to override the output of rate in our own theme such that we can insert markup for a title above the five-star, for example?
i.e. the override code would go in our own theme, here, for example: sites/all/themes/mytheme/template.php
If so can you supply the function to override?
Comment #15
therobyouknow CreditAttribution: therobyouknow commentedj0sh - some advice requested please on your comment #2 ( https://drupal.org/comment/reply/940532/3779918 )
- where is this snippet placed? I placed in the template.php file in my theme - in path: sites/all/themes/mytheme/template.php where 'mytheme' is the name of my theme. I aldo renamed the function from phptemplate_rate_button to mytheme_rate_button - is this correct?
- what version of rate are you using? I am using 7.x-1.x-dev
- does your fix require patch rate-theming-940532.patch (comment #13 / https://drupal.org/node/940532#comment-6950932 / https://drupal.org/node/1891422 ) or if it does not require this patch will your fix still work with it?
When I tried placing your code in template.php as I described above I got the following errors below, specifically complaining about parameter 1 not being a string and missing argument 2 - these errors are unexpected to me as your function defines all three parameters that are required by the function prototype.
However I changed a few lines of your code to retrieve the argument parameters in slightly different approach and this remedied the problem as these errors did not now occur (however still not provided title above the rating):
I see the widget title appear BUT near the top of the page and not close to the five star widget at all.
Also the five star widget has its styling removed so now appears as numbers 12345 but hovering on them restores the star graphic symbols.
(Testing on Chrome)
Comment #16
therobyouknow CreditAttribution: therobyouknow commentedThe problem with the incorrect position of the title is that echo() function is being used, the title markup is not being output by the same method that the widget is being used to output - the other already existing markup is outputted as what function returns as its return value.
Also, this
_rate_button override gets called several times (up to 5) for each star printed on the screen. So not the ideal place to put display title functionality. Thoughts?
I think geert had a better idea to output the title markup along with the other markup, here: https://drupal.org/node/940532#comment-5094640
An even better solution would be to add a check box 'show title' in the edit form for the widget. I've made a start on this but now need to learn about how this is installed in the database AND also the database upgrade path for adding this extra boolean path if I make a patch with this feature.
Thoughts?