Hi everyone!
I think that the documentation actually available isn't enough to make a custom template.
I've copied the rate-widget.tpl.php to rate-widget-NAME.tpl.php (NAME being the machine readeble widget name setted in administration panel - just as is explained in the README) and put an additional html paragraph just to test the template working. But it don't.
What's missing to make it work?
Thanks in advance!!!
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | rate-custom_template-1262438-16.patch | 662 bytes | ronino |
Comments
Comment #1
mauritsl commentedThe name should be rate-widget--NAME.tpl.php, with 2 dashes. Does that fix your problem?
Comment #2
danilocgsilva commentedNo, it don't!
Comment #3
danilocgsilva commentedSorry for saying, but it seems that it was never able to make a custom template.
Tested in 6.x-1.2, 6.x-1.1, 6.x-1.0 and 7.x-1.1-beta1. None of them works with the following procedures:
gngboth as machine readable name and tag)rate-widget.tpl.phpcontaining a html paragraph just to watch de template modificationrate-widget.tpl.phptorate-widget--gng.tpl.php(in the same location) and modify (or create, if it was not done before) the content of paragraph to watch the result in the site.Doesn't worked.
Someone can assure that the module actually does let themers creates yours own custom widget templates or there are a real bug on the module?
Thanks in advance!
Comment #4
pierrecw commentedHello,
I've the same problem !! But in the 7.x-1.2 version.
I've a rate widget "custom" call All rate (machine name = all_rate). When i create rate-widget--all-rate.tpl.php the template don't work !
@danilocgsilva do you find a solution ?
Comment #5
danilocgsilva commentedNot as I would like.
My "solution" was to modify the css and tpl.php of one of the default templates, so I make the look I want. So, standardized modifications have to be maden everytime the module is changed (I wish that the next code administrator pay attention on the outsider files inside module that teaches what modifications have to be maden to preserve the widget look...)
Custom template continues useless...
Comment #6
yang_yi_cn commentedok, I finally got it working.
The point is, you need to have 2 template files in your theme:
rate-widget.tpl.php
AND
rate-widget--your-widget-name.tpl.php.
Without the first one (original template file), the Drupal theme system will not recognize the second one. I tested that on the 7.x release but should be the same for 6.x.
Comment #7
jim005 commentedYour solution isn't working for me. So I copy the module Rate into /example.com/modules/ then edit the original tpl : thumbs-up-down.tpl.php
Thanks to fix this issue :-)
Comment #8
mototribe commentedit doesn't work for me either.
My rating widget is called rate_updown and I have the rate-widget.tpl.php and rate-widget--rate-updown.tpl.php in my templates directory. But they don't override the module template.
Comment #9
vlad.dancerHere how I implemented it. For me it's needed that rate template will be in my module and widget type was "+1".
Solution for theme:
mytheme_preprocess_rate_template_number_up_down) and define theme_hook_suggestions (ex:).
rate-template-number-up-down--mytheme.tpl.php).Solution for module:
Just as I said about, but we need to say theme that our module has some templates for it too). In
mymodule_theme()add this line:I hope that this will help someone!
Comment #10
sepehr.sadatifar commentedmy custom template works without the base template (rate-widget.tpl.php) but the problem is that it doesn't recognize `$up_bottom` and `$down_button` so there is no `a` tag and in result functionallity is broken.
[edit]: sry `$up_bottom` and `$down_button` is only for `number-up-down` widget type , for custom widget type you can use variables defined in base template file (`rate-widget.tpl.php`).
Comment #11
vlad.dancerUse hook_rate_templates to define own template and widget and after that add preprocess theme func add define your buttons
Comment #12
MD3 commented@vlad.dancer thanks so much! You're a genius!
Just to clarify the instructions: you need to create your own custom module for this work. So:
You should have the following files / folders in: sites/all/modules/ownmodule:
Good luck!
Comment #13
vlad.dancer@MD3
Thx a lot for summarizing.
Comment #14
webdrips commentedHere's my fivestar theme-only approach thanks to @vlad.dancer (#9)
function MYTHEME_preprocess_rate_template_fivestar(&$variables)rate_preprocess_rate_template_fivestarThis gives you two places to override the output, so you should be able to achieve the desired output.
Comment #15
ronino commentedWell, I can confirm that it doesn't work as described in the README.txt:
So shouldn't this be considered a bug report?
Did it ever work? Otherwise it wouldn't be in the documentation, I guess. Those hooks and theme functions described above shouldn't be necessary, should they? For example, using THEME_preprocess_rate_template_yesno() to define a custom template only works for ALL yes/no widgets, not a specific one as it is expected with rate-widget--NAME.tpl.php.
Comment #16
ronino commentedThe attached patch fixes the issue and makes custom widget templates be recognized and used as described in README.txt. The problem were lines 238 to 243 in rate.module:
The first two lines correctly set e.g. "rate_widget__my_widget" and "rate_widget" as template suggestions. But the 3rd line always overwrites those and sets e.g. "rate_template_yesno" as the one and only.
The patch now makes templates be used in the following order (if existent):
Comment #17
mauritsl commentedCommitted to GIT. Thanks!
Comment #18
Lythimus commentedrate-template-yesno.tpl.php worked fine for me.
Comment #19
ronino commentedLythimus wrote:
It should work with and without the patch. Didn't it for you? Where did you put the template?
Comment #21
ivnish