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.
Hi, I try to make the widget available as a field in the layout screen of DisplaySuite module. Creating a new field whith at admin/ds/nd/fields using following code:
but I don´t now to look for the rate widget id.
$widget_id = 'the id of the rating widget here';
print rate_generate_widget($widget_id, 'node', $object->nid);
If you can help me please
thanks
Comment | File | Size | Author |
---|---|---|---|
#39 | rate-ds-1069906-39.patch | 1.85 KB | dtarc |
#38 | rate-ds-1069906-38.patch | 1.69 KB | dtarc |
#37 | rate-ds-1069906-37.patch | 3.5 KB | gildir |
#36 | rate-ds-1069906-36.patch | 3.39 KB | gildir |
#35 | rate_ds.zip | 1.41 KB | mach5_kel |
Comments
Comment #1
jonlhouse CreditAttribution: jonlhouse commentedHi. I'm having similar problems with display the rate widget with Display Suite. I'm using the dev version of rate (7.x-2.x-dev) and the 7.x-2.4 voting-api module.
For my needs I'm creating a "yes/no" vote widget for a agree/disagree vote (machine name: agree_disagree_vote) on a specific node content type. I've read through your readme and tried a number of different hacks including:
<?php print $node->rate_agree_disagree_vote['#markup']; ?>
directly in my custom display suite layout .tpl file. The contents of $node that display suite was "seeing" didn't include any array prefixed with "rate". I also tried creating a custom vote widget using the steps you outlined with the same result (not much).
When I disabled display suite the "agree" and "disagree" buttons appeared in my full node view but were text only (no link to submit a vote).
Specific to display suite the above poster suggested adding a custom field to display suite which sounds like a good idea. However, I can't figure out how to get from the exposed $entity object to your specific rate field to do a print on rate_NAME ['#markup'];.
Also, probably worth a category of its own but have you looked into created a field that can be used in the D7 field UI that way the location and style can be managed with some of the new mods (panels3, display suite).
I'm new to drupal and php (my background is java and C) and I'm learning this as I go, so sorry for any silly questions.
Comment #2
mauritsl CreditAttribution: mauritsl commentedI will take a look at ways for a clean integration with ds, but for now you may use the rate_embed function:
print rate_embed($node, 'agree_disagree_vote', RATE_FULL);
Comment #3
jonlhouse CreditAttribution: jonlhouse commentedThanks!
Comment #4
jonlhouse CreditAttribution: jonlhouse commentedQuestion: Where do I put the custom .css file and what is the naming convention for a custom rate widget?
Things seem to be working better, I'm getting the stock widgets to work. I'm having trouble getting a custom widget css to work though. I've created a custom widget called "agree_disagree" and have created the "rate-widget--agree-disagree.tpl.php" file and placed that in themes/mytheme/template. That is working well (full control over the output).
The css include for this custom widget isn't working though. I've created a custom css file (based on the yesno.css template) and renamed the class variable to match the tpl generated html. I've verified that css class names in the .css file match the html output as shown in firebug.
I've tried the following locations: site/all/themes/mytheme/css, sites/all/themes/mytheme/templates (where the custom .tpl file is) and the following naming conventions: rate-widget--agree-disagree.css, agree-disagree.css. Any further help would be much appreciated. Thanks.
Comment #5
andrebonfanti CreditAttribution: andrebonfanti commentedsubscribe.
Comment #6
TimelessDomain CreditAttribution: TimelessDomain commentedI tried #2 by putting the coding here as a custom field w/ php filter http:/yoursite.com/admin/structure/ds/fields/manage_custom, but it did not work/
Another work-around: now that views integration is possible - #1083250: widget tag not showing up in views relationship. You could use a views reference field for the actual nodes & use the NID from url argument. Or even better, use http://drupal.org/project/viewfield now that it finally has a d7 branch
Comment #7
ozsi CreditAttribution: ozsi commentedDS uses the $entity variable, so you can use this code:
Comment #8
hedley CreditAttribution: hedley commentedI'm adding rate as a custom display suite field, in a custom module:
Just change 'like' to whatever the machine name of your widget is, and MYMODULE to your own modules name.
Comment #9
pedrospI assume because of the "entity" stuff, this code is no compatible with the D6 release.
Any tips on how to integrate Rate onto Display Suite for D6 version ?
Talking about performance is it better to go with custom field or custom module ?
Thanks
Comment #10
drew29 CreditAttribution: drew29 commentedHej,
when I put the code
in a custom display suite field and change the input filter to display suite code nothing will be display in my frontend :-(
can you help me to solve this problem?
kind regards
drew
Comment #11
joelrotelli CreditAttribution: joelrotelli commentedThanks, #8 works perfectly, you should try this #10 !
Comment #12
pardalman CreditAttribution: pardalman commentedHi,
Adding the code:
$widget_id = '1'; // the id of the widget as shown in the url of the rate widget (in this case 1)
print rate_generate_widget($widget_id, 'node', $entity->nid);
Works fine for showing the widget on the content but what about showing the rate widget for comments? how can this be made?
Thanks in advance!
Comment #13
XmhO CreditAttribution: XmhO commentedI haven't tried but I guess that if you replace "node" with "comment" and "$entity->nid" with "$entity->cid", It should work.
Comment #14
RKopacz CreditAttribution: RKopacz commentedI'm trying to do the same thing, generate a widget in a display suite code field, and I cannot get anything to work.
I've tried the rate_embed function but continue to get an error
'Trying to get property of non-object in rate_embed() (line 743 of /opt/lampp/htdocs/sf_new/sites/all/modules/rate/rate.module).
I'm going to try to write the module suggested in #8 next, but it seems to me one should be able to embed this as a code field in DS. I've looked at that line but I'm not enough of a PHP ninja to figure it out :(
Comment #15
XmhO CreditAttribution: XmhO commentedIt should work fine. Maybe you're not specifying appropriate parameters in your rate_generate_widget() function.
Comment #16
Erik Seifert CreditAttribution: Erik Seifert commentedCreate your custom module
Comment #17
XmhO CreditAttribution: XmhO commentedWhat is the difference with #8 ?
Comment #18
Erik Seifert CreditAttribution: Erik Seifert commentedYou can choose the rate widget in the ds settings.
Comment #19
Erik Seifert CreditAttribution: Erik Seifert commentedHere the correct version.
Comment #20
JRZ-2 CreditAttribution: JRZ-2 commentedThanks ! it works perfectly.
Comment #21
Erik Seifert CreditAttribution: Erik Seifert commentedNew Version of Integration for Display Suite:
- Add support for comments
- Add support for Display Mode (Compact,Closed....)
Could be go as submodule into rate module
Have Fun
Comment #22
aalireza CreditAttribution: aalireza commentedhi, i installed this module ,
how work? this module add new field "Rate integration" i enabled Rate integration but not showing rate module.
Comment #23
Erik Seifert CreditAttribution: Erik Seifert commented- Install Module
- Add new Rate widget
- A new field should appear in DS Settings for a content type
Comment #24
deanflory CreditAttribution: deanflory commentedStep 4: - Click settings cog icon and choose which widget to use
Step 5: - Save the Manage Display form to save the settings to your node type for that Display Suite display mode
Thanks erikseifert! It worked as expected and with an existing widget (in case anyone needs to know that you don't have to create a new widget to get it to work).
erikseifert, you should definitely add this as a module or submodule to ensure more people can find it and use it, otherwise it would be nearly impossible to find again without these keywords below or rummaging through countless issues:
Rate Display Suite
Rate DS
rate_ds
rate-ds
rate_field
rate-field
Rate Field
rate_ds.zip
Comment #25
therobyouknow CreditAttribution: therobyouknow commentedIt is not clear from these comments which "Field type" is needed for a new rate widget - Integer? Decimal?
What are the complete steps for using the code provided in comment #19 ( https://drupal.org/node/1069906#comment-7047316 ) ?
erikseifert states some of the steps in comment #23 https://drupal.org/node/1069906#comment-7466882
and deanflory appears to added to erikseifert's steps in #24 https://drupal.org/node/1069906#comment-7558959
Let me have a go at creating the full steps:
1) create a module and paste in code from #19 ( https://drupal.org/node/1069906#comment-7047316 ) ? Specifically just paste the whole code from comment #19 into your .module file, nothing else needed
2) enable the module
3) create a new rate widget in admin/structure/rate
4) create a new field admin/structure/types/manage/resource-article/fields
- now here's where I need advice (where I get stuck as described above) - when I create a new field, I:
enter the word Rate beneath "Add new field" then for field type I'm not sure what to use: Decimal? Integer?
and then finally when I try to choose the rate widget from the widget drop down, it's not there, only "Text field"
Comment #26
fantom84 CreditAttribution: fantom84 commentedfor module in the #21:
if DS version 7.x-2.x we need to add 'settings' => array() in properties array in the rate_ds_ds_fields_info() function:
without this function rate_ds_ds_field_settings_form($field) don't call
Comment #27
Erik Seifert CreditAttribution: Erik Seifert commentedYou don't need to add a field. You must only add a widget in admin/structure/rate . After this a new Display Field appear under manage display.
Comment #28
Erik Seifert CreditAttribution: Erik Seifert commentedThanks, i will update this module as soon as possible.
Comment #29
adam7 CreditAttribution: adam7 commented#21 & #26.
We also need:
Comment #30
gmario CreditAttribution: gmario commented#29
and last (when you are configuring fields visible in display's tab for a content type: admin/structure/types/manage/your-content-type/display) you have to configure field settings of Rate integration (click on gearwheel at right side) to choose which rate's widget has to be used
a si biri
gmario
Comment #31
mahipal46 CreditAttribution: mahipal46 as a volunteer and commented#8 worked for me. Thanks.
In rate_embed($field['entity'], 'like', RATE_FULL); replace 'like' with your tag name specify in your rate widget.
Comment #32
bburgThis patch takes the module in #21 and subsequent suggestions and integrates them directly into the rate module. Works for me.
Comment #33
bburgIn hindsight, "Rating" would be a better title for the ds field...
Comment #34
gildir CreditAttribution: gildir commentedAlternative integration with DS. Creates one field per widget (in case there is the need for multiple rate widgets on a page) and follows the show/hide options in the rate module instead of in the content type field display mode layout.
Comment #35
mach5_kel CreditAttribution: mach5_kel commentedHere is an updated version of the rate_ds module with the suggestions posted above added. Ie #21 , #26, #29.
I tested it with the latest dev version of rate module and it appears to be working correctly. Thank you for the suggestions above. So far this is the easiest (working) solution.
Comment #36
gildir CreditAttribution: gildir commentedSmall adjustment to patch in #34 for anyone interested in that one. Reminder: this is an alternative approach than the primary one suggested in this thread for people who either need more than one widget per page and/or want to use the rate module show/hide options settings.
Comment #37
gildir CreditAttribution: gildir commentedAdditional bug fixes from #36.
Comment #38
dtarc CreditAttribution: dtarc commentedI couldn't get the patch in #37 to apply, it seems like it is in some kind of weird binary format. Here's a reroll.
Comment #39
dtarc CreditAttribution: dtarc commentedUpdated patch with a bug fix for comment display.
Comment #40
Knud CreditAttribution: Knud commentedThe module at #35 seems to work very well, nice and easy. Thank you !
Comment #41
sinasalek CreditAttribution: sinasalek commentedModule in #35 works like a charm against the latest dev version,
Thanks a lot :)
Comment #42
Sigvard CreditAttribution: Sigvard commentedOkay I am a bit confused now.
I run DIsplay suit 7.x-2.6 and Rate module 7.x-1.6.
Ratings show up on comments but not on my actual content. I use a Number up/down widget for nodes and comments (same widget for both). The option to rate things (and the current rating) shows up for comments but not for nodes.
Which version of the patches/modules above should I download? And can someone give me a brief installation guide (I am very weak in Drupal-work and does not know how to apply patches)
Comment #43
Sigvard CreditAttribution: Sigvard commentedInstead of patches I think it is much easier to use the original askers code but refer to $entity rather than $object.
I jsut added the following code in a code field (text format display suite code).
Widget ID:s are easy to guess as the first widget got ID 1 and the second one ID 2 etc. Trial and error solved that for me.
Comment #44
jaydee1818 CreditAttribution: jaydee1818 commentedPatch #39 works for me. Any chance this feature will be rolled into the module?
Comment #45
chilic CreditAttribution: chilic commentedPatch #39 works for me.
Comment #46
phamkhaclam90@gmail.com CreditAttribution: phamkhaclam90@gmail.com commentedThe rate_ds module is useful for our project. Please push it as a Drupal project if you can, thanks!
Comment #47
Erik Seifert CreditAttribution: Erik Seifert commentedI can open a project, but i cant maintance this project. Anybody here to become a maintancer ?
Comment #48
yannickooA new project for this integration? It's cooler to put the Display Suite integration into Rate.
Comment #49
Erik Seifert CreditAttribution: Erik Seifert commentedYep.
But this solution do not find a way in to this module since 3 Years.
Comment #50
mauritsl CreditAttribution: mauritsl commentedErik, I have sent you a message via the contact form about this issue. I'm open for the possibility to maintain this within the Rate module.
Comment #51
deanflory CreditAttribution: deanflory commentedCommitted to Rate?
Comment #52
doxigo CreditAttribution: doxigo commentedseriously what happened to this feature? can anybody just integrate this with rate module ?
Comment #53
jonraedeke CreditAttribution: jonraedeke commentedPatch #39 works for me beautifully.
Comment #54
BarisW CreditAttribution: BarisW commentedPatch in #39 works great. Please commit.
Comment #55
alibama CreditAttribution: alibama commented#35 worked fine, #39 worked fine - both are roughly equivalent... neither worked off the shelf with drupalgap, but that's probably not the fault here...
Comment #56
Dajka CreditAttribution: Dajka commented#39 worked for me too. Thank you.
Comment #57
kopeboy CreditAttribution: kopeboy commentedCan the maintainers please commit this?!?
Is this still valid for version 1.7?
Comment #58
NikGleb CreditAttribution: NikGleb commentedIn my opinion, the way to sub-module #35 is a more flexible solution. It has the ability to customize the widget display option, depending on the mode of output (and not only in the Rate module settings - default and teaser).
My site has a lot of view modes the output content (default, teaser, list, etc.) and for each mode I can adjust the display type of the widget.
With patch #39 I did not see such a possibility.
Comment #59
jOksanen CreditAttribution: jOksanen commentedThis is a really critical issue for me on using this module. I hope that a solution is provided and committed soon.
I agree with NikGleb (#58). The sub-module approach seems simply cleaner to me. Adding that Zip into github to use it in drush make builds for now.
Comment #60
ezoulou CreditAttribution: ezoulou commented#39 works for me (rate version : 7.x-1.7).
It is simple and does what I expected : create a fieldable rate widget on a display suite layout. thanks.
Comment #61
dtabach CreditAttribution: dtabach commentedI tried some of the approaches here, patch to rate module (#39), independent rate_ds module(#35), and creating a code field with Display Suite (#43) and they worked, but with the same little bug.
The 'Thumbs up/down' full widget does not display correctly in full node view.
It works in teasers as expected.
But in the full content page, it shows as if no one had ever voted , showing 50%-50%. When someone votes, it briefly behaves correctly, showning the text "You voted '[up/down]' ", but it returns to its previous state when the page is refreshed.
I described the bug here: https://www.drupal.org/node/2913010
Now I see this isn't a Rate module bug, but related to Rate integration with DS.