Closed (fixed)
Project:
Smackdown
Version:
6.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
12 Sep 2010 at 04:53 UTC
Updated:
4 Feb 2011 at 06:16 UTC
Jump to comment: Most recent file
Comments
Comment #1
sirkitree commentedIf you take a look at the javascript (Drupal.behaviors.smackdown) you'll see it is targeting specific classes. You must make sure that these are present for the voting to work.
Comment #2
jomg commentedAh thank you!
Comment #3
jomg commentedSorry I'm really new to this. I still can't seem to get it to work...
The link doesn't get processed as a vote, and only goes to the node.
I tried adding class="smackdown-processed" and a lot of the higher class tags as well.
It works simply with
print $content... but I have no idea what it's finding. I have tried using firebug and dev module.I can't seem to spot where there are any other classes in the javascript:
/**
* Attach the smackdown behavior to nodereferences on the page.
*
* @param context
* The jQuery object to apply the behaviors to.
*/
Drupal.behaviors.smackdown = function(context) {
if (typeof Drupal.settings.smackdown !== 'undefined') {
var field_1 = '.field-' + Drupal.settings.smackdown.field1.name.replace(/_/g, '-');
var field_2 = '.field-' + Drupal.settings.smackdown.field2.name.replace(/_/g, '-');
if (Drupal.settings.smackdownPerm == 1) {
Drupal.smackdown.attachVote(context, field_1 + ' .field-item a');
$(field_1 + ' .field-item a').attr('rel', Drupal.settings.smackdown.field1.nid).addClass('smackdown-processed');
Drupal.smackdown.attachVote(context, field_2 + ' .field-item a');
$(field_2 + ' .field-item a').attr('rel', Drupal.settings.smackdown.field2.nid).addClass('smackdown-processed');
}
else {
Drupal.smackdown.attachNotice(context, field_1 + ' .field-item a');
Drupal.smackdown.attachNotice(context, field_2 + ' .field-item a');
}
}
};
Comment #4
sirkitree commentedYou first have to know what the variable here is. What is your field name? Smackdown stores the field name in Drupal.settings.smackdown.field1.name and Drupal.settings.smackdown.field2.name - the then var field_1 and var field_2 become field-[your-field-name]. So if you field ( in cck ) is called field_smackdown_1, Drupal.settings.smackdown.field1.name should have a value of smackdown_1 and then var field_1 will hold the value '.field-smackdown-1'.
Smackdown then attaches the voting function to $('.field-smackdown-1 .field-item a'). So you must make sure this is how your DOM is setup in your final theming. It then sets the rel property of this DOM element to the nid, which should be recorded in Drupal.settings.smackdown.field1.nid, and adds the class '.smackdown-processed'.
Please let me know if this helps.
Comment #5
jomg commentedThanks for your response. I think I can understand how the javascript function works in that sense, but I don't now how it call the function.
I'll try to explain better what I'm doing.
My field name is field_war1 (in cck).
I created a new template for node-smackdown.tpl.php (which is being used properly by the content type), inside which I am trying to call specific pieces of the node referenced in the smackdown node so I can arrange/theme them:
print $war1->titleThen I turn the title into a link so it can be used to vote. But then there is no part that tells smackdown.js to do anything I guess, which is why it doesn't work (?). I'm not sure what to add. I guess my DOM is net setup properl, but I'm not totally sure I understand what that's about.
Or even easier, I want to show both nodes as they are but have them side-by-side rather than vertically stacked as they show in default with:
print $contentIdeally I want to create a smackdown node like this.
| ------------ | | --------------|
| NODE1 |vs| NODE2 |
|-------------| |--------------|
[Vote1] [Vote2]
Thanks in advance for any help.
Comment #6
sirkitree commentedMaybe if you attach your actual .tpl file I can help a bit more.
Comment #7
jomg commentedThanks. I have attached the tpl. I really appreciate the help.
Comment #8
sirkitree commentedYou are giving the anchor tag the 'smackdown-processed' class. This is incorrect. 'smackdown-processed' should _only_ be given by smackdown's javascript. It's simply a way for the javascript to know that it has already attached itself to an element.
Beyond that, I can't really tell what you're trying to accomplish with this .tpl file. I assume that your 'smackdown' node type is called 'battle' and you are then trying to theme this node type.
It would probably be much easier for you to utilize the template_preprocess_node() in your template file that to try to create a tpl file for this node type.
You say that the
$contentvariable is working just fine, so I suggest that you mimic the HTML structure that it is producing, changing as little as possible. I'm not sure I can really help you much more than that.Comment #9
jomg commentedOk. Thanks for the help. I'll see what I can do.
Comment #10
sirkitree commented