Wookiee
Forum Replies Created
-
No worries..glad it worked
Always remember, you can see which stylesheets are loaded in any page by just viewing the source. Right click > view source in your browser, then just search and find “.css”
That way you can be sure on any given page which stylesheets are being loaded.
If something doesnt work once you have made changes to your stylesheet, just check if the stylesheet is actually loaded.
I only put the source code in the gallery stylesheet because if I ever decide to uninstall the plugin, i dont sit with unwanted code in my MAIN template code… if that makes sense, but any stylesheet that is loaded in ur page would make it work.
Hey Rico
I’m doing this off my mind at the moment, so hopefully it will work.
You should put the style code in the nextgen plugin stylesheet, not the voting stylesheet.
Yours should go here:
/plugins/nextgen-gallery/css/nggallery.css
OR HERE but try the first mentioned above first
/wp-content/themes/mydog/style.css (this is your template stylesheet)
Hope it works.
Thanks Shauno.
Got it all set up and working, boy was it a mission.
If anyone wants to see the query, i got it working like this:
if($wpdb->query("DELETE FROM ".$wpdb->prefix."nggv_votes WHERE user_id = ".$wpdb->escape($user_id)." AND pid IN ( SELECT pid FROM ".$wpdb->prefix."ngg_pictures WHERE galleryid = ".$wpdb->escape($gallery_id)." )") !== false) { //It has been deleted, celebrate! } else { //It has not been deleted, oh no! }Where the galleryid and user_id is both sent to my function that deletes the vote. This is only the query part of things… lots of other code left out. The query only executes with $wpdb->prefix. I have no idea why as manually using the prefix just results in it not being deleted…
Big *sigh*
Thanks again for the query tips! I just hope this is secure enough! lol
Hi Shauno
I see the gid (gallery id) in ngg_votes is inserted only when you vote on a gallery. If you are voting on an image, it is set to ‘0’ (zero)?
This actual gallery id $config[“gid”] is probably only set for gallery voting for running other queries to see when a gallery has been voted for?
Is this the only way to check if a gallery has any votes? If there is actually a gid thats not == 0?
I know this requires some tweaks, but wouldn’t it be “better” for lack of a better term, if the gid got inserted whether it was a vote for an image or gallery, and having an extra database column like type, where type = 1 means its a gallery vote, and type = 0 means its an image vote?
That way running queries on what you actually have in your ngg_votes can be easier?
The reason im asking is because i actually managed to get a very basic delete button working, but it only works on the user_id. So it deletes ALL votes from that specific user in the ngg_votes table.
Thanks for explaining the vote system database end. It makes sense now, I did not run any star rating related tests (thats my bad).
You have done an awesome job with the plugin. It’s got all the basics(and more) to be the best voting/rating plugin out there. I sincerely mean that.
The delete function.
I just thought that would be good in most situations. Like when a new image gets uploaded, but you only want a user to be able to have one vote in a gallery. Then those users that already voted in that gallery can not vote for any new images. Unless… he can change his vote.Anyway. Im not giving up, I was clearly the one sketching images on my php handbook back in UNI… but im sure my brain must have heard something that was going on in class!
Thanks Shaono!
PS. It seems you have something in mind I havent thought about :p
Hey Shauno
I am trying to create a dynamic button to delete the vote I cast on an image for a specific gallery from the front end, according to some info I found here:
http://ww.wp.xz.cn/support/topic/wpdb-how-can-i-make-text-link-to-delete-rows-in-two-tables?replies=2I have done the following:
In my templates functions.phpfunction delete_my_vote_func($user, $gid) { global $wpdb; $wpdb->query( " DELETE votes.* FROM wp_nggv_votes AS votes LEFT JOIN wp_ngg_pictures AS pics ON votes.pid = pics.pid WHERE votes.user_id = ".$wpdb->escape($user)." AND pics.galleryid = ".$wpdb->escape($gid)); }Then from another function, dynamically, the user_id and gallery_id he currently is viewing is sent to the function as follow:
$link_remove = '<a href=""><input type="submit" name="delete_vote_button" value=" Delete Vote " onclick="<?php delete_my_vote_func('.$user.','.$i.'); ?>" /></a>';Where $i is the gallery_id he is currently viewing.
Where $user is the current user_id.
The parameters are sent & received correctly (I double checked)The link is then displayed on the front, i just didn’t copy my whole function in here.
Link does not delete any records though. Do you know how this would be possible to fix and how safe would this be to enable users to delete their votes from the front end?
Thanks man.
Yeah i figured without going and altering both gallery and voting plugins there is not much hope for this at the moment.
Thanks for your quick response though! 🙂
Important update:
There is an issue with the javascript file above in step 2.
2) nextgen-gallery-voting\js\gallery_options.jsI have made a mistake, I’m sorry >.<
Whats wrong?
– Gallery Voting options disappeared when you view/manage a galleryFix:
Either make the fix manually like this:Line 123
Change this:
html += '<td>'+(nggv_votes_list[i][0] == 100 ? 'Like' : 'Dislike d>';To This:
html += '<td>'+(nggv_votes_list[i][0] == 100 ? 'Like' : 'Dislike')+'</td>';Or
Copy the whole code over from here:
Complete file:http://pastebin.com/n4D6mZNAIt’s impossible for the code changes to wipe your current votes. The code changes has nothing to do with the current votes already stored in the database.
The output is changed however, so it will “not show” any dislikes that has already been “voted”, but the votes are still in your database. This simply removes the button (dislikes) and leaves you with only 1 button to click.
DEMO HERE: http://www.myboksquad.co.cc/voting-for-loose-head-prop/
I will list the changes again, but I have made extra changes which I will explain in detail:
1) nextgen-gallery-voting\ngg-voting.php
a Removed all traces of dislike
b Changed the word Like to Vote
c Added css classes
– This is to have a hover state for the button (in css)
– The css code is added in point no 3 belowCOMPLETE FILE WITH CHANGES
http://pastebin.com/TPRDurTh2) nextgen-gallery-voting\js\gallery_options.js
a Removed the output for dislikes
COMPLETE FILE WITH CHANGES
http://pastebin.com/51ayAB313) The CSS
You will need to add these CSS styles to your stylesheet:
\nextgen-gallery\css\nggallery.cssa Added div class=”like_button” around the Vote button
– You can set the width as you want
– You can set the background colors to what you wish
– You can even use images as backgrounds if you wish
– I have used nasty colours in the code below, but its to show you what colours goes where.– NOTE: there is no button text as that is removed in ngg-voting.php, this is because I have used background images with the word Vote on my button images. So using the css below, will only result in blank but working buttons. To enter words in your buttons instead of having background images, read point 4 below.
.like_button a:link, .like_button a:visited { width:90px; height:30px; line-height:30px; background-color:#FF0000; border: 0px solid #33FF00; display:block; } .like_button a:hover, .like_button a:active { width:90px; height:30px; line-height:30px; background-color:#3333CC; border: 0px solid #FF6633; display:block; }d Added span class=”like-results-text” around the word Vote/Votes
– Because I want the results (amount of votes) to look different from the word Vote or Votes.like-results-text { color:#a4a4a4; }4) Adding text to button.
To have ANY word appear on the buttons instead of going out to create background images with the word on the images itself
In file ngg-voting.php (TWO changes)
Find:
$out .= '<div class="like_button"><a href="'.$url.'gid='.$gid.'&r=1" class="nggv-link-like"> </a></div>';Change to:
$out .= '<div class="like_button"><a href="'.$url.'gid='.$gid.'&r=1" class="nggv-link-like">MY TEXT</a></div>';Find:
$out .= '<div class="like_button"><a href="'.$url.'ngg-pid='.$pid.'&r=1" class="nggv-link-like"> </a></div>';Change to:
$out .= '<div class="like_button"><a href="'.$url.'ngg-pid='.$pid.'&r=1" class="nggv-link-like">MY TEXT</a></div>';That should be it. Let me know how it goes. I have NOT tested the output (the look & feel) of voting for a gallery, ONLY voting for images.
I’m not 100% sure, but Shauno (the original developer of this plugin) Should have the Like only option available in a next release. so up to you if you think this is too much work, but it works perfectly for me.
Crap lol sorry bout that. Hope it helps
Solved it Shauno. I had to include the following code to get it to work for the genesis child theme.
function script_managment() { wp_deregister_script( 'jquery' ); wp_deregister_script( 'jquery-ui' ); wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' ); wp_register_script( 'jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js' ); wp_enqueue_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', array( 'jquery' ), '4.0', false ); wp_enqueue_script( 'jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js', array( 'jquery' ), '1.8.16' ); } add_action( 'wp_enqueue_scripts', 'script_managment', 99);Thanks a million for the javascript code. Seriously man you rock.
Progress
1) Javascript > check
2) Stylesheet > check
3) ajaxify-likes > check
4) tests > success!Mark as resolved?
Omg Shauno, wait, I got the javascript loaded, its just not in the correct area.
It loads it in the footer when using:
wp_enqueue_script(‘jquery-ui-dialog’);
Thats a bit strange i’d say.
Progress
1) Get the javascript loaded > Check!
2) Get the stylesheet loaded > in progress…
3) Change ajaxify-likes.js > not there yet….
4) run some more tests > do i really have to…Ok, voting is enabled only for jersey no 1, results can be seen on the results page (still working on short codes for the results) but thats another day’s issues! I’ve worked my way around that for the moment
Oh voting is currently disabled as well, as i said still working on structure and populating the content, but the voting works perfectly as is.
So if you cant see the voting oh wait ill enable it anyway….might be worth the tests
Hey Shauno
I have tried this before as well:
wp_enqueue_script(‘jquery-ui-dialog’);
No javascript gets into the page that way. It simply doesnt work! Im on a genesis child theme (still reading for this solution)
The JQuery UI dialog requires the following 3 javascript files and 1 css to work standalone local server. (which works perfectly)
1) jquery-ui.min.js
2) jquery.min.js
3) custom.js (it contains the following code)[ Moderator note and edited, please use backticks or the code button for posting code samples. ]
$(function() { $("#box").dialog( { title: 'Voting', width: 400, height: 200, modal: true, resizable: false, buttons: [ { text: 'Yes', click: function() { alert('You just voted'); $(this).dialog('close'); } }, { text: 'No', click: function() { $(this).dialog('close'); } } ] } ); });4) jquery-ui.css
This is what i have tried so far:
1) Added the 4 files into my template theme with:
wp_enqueue_script(‘custom-script_1’, get_home_url() . ‘/wp-content/plugins/nextgen-gallery-voting/js/jquery.min.js’);
wp_enqueue_script(‘custom-script_2’, get_home_url() . ‘wp-content/plugins/nextgen-gallery-voting/js/jquery-ui.min.js’);
wp_enqueue_script(‘custom-script_3’, get_home_url() . ‘wp-content/plugins/nextgen-gallery-voting/js/custom.js’);
wp_enqueue_style(‘custom-style_1’, get_home_url() . ‘wp-content/plugins/nextgen-gallery-voting/css/jquery-ui.css’);Result:
They all get included properly BUT there is a conflict with jquery.min.js, once i remove that, no conflict is detected. But clearly on local tests, it is required for jQuery UI2) I added a <div id=”box”>Are you sure you want to vote for this image</div>
The result:
The div appears fine on the gallery page, but its content is not being influenced by the javascript (or css for that matter).I will link you to the site im working on. None of the above has been done LIVE, im ONLY doing this locally first. And please bare in mind, its still under construction. LOTS of work needed, but same as you man, need to find the time to work on this. NOTE ITS ONLY dummy content at the moment too!! Need to get in touch with the rugby unions, supersport haven’t responded so far…
I have tried your recommendation above, but nothing changed. I will go about this again step by step slooooowly and let you know how it goes. I still need to reference your ngg-vote-confirm div somewhere… I tried to change my id=”box” to id=”ngg-vote-confirm” but that didnt work either… Think its all just javascript conflicts at the moment… SIGH lol