Tips and Tricks About Computers, Web Development, Linux, the Internet and the Like
Patching NextGEN Voting Plugin to Allow Showing of the Vote Form on Single Images
Intro
NextGEN Voting is a plugin for the wordpress plugin NextGEN Gallery plugin. Keeping this in mind made the task of extending easier. NextGEN Gallery hooks into wordpress functions, NextGEN Voting hooks into NextGEN Gallery.
By default, NextGEN Voting hooks into the gallery view, giving access to a function that uses the image id for lookup. The only reason we see nothing if we try to paste the same template code into a page other than the recommended “nextgen-gallery/view/gallery.php” is because that function is not given access in any other view.
How-to Add Access to Use the Function in the Image Browser Template
Open “wp-content/plugins/nextgen-gallery-voting/ngg-voting.php”,
Look for:
add_filter("ngg_show_gallery_content", "nggv_show_gallery", 10, 2);Add After:
add_filter("ngg_show_imagebrowser_content", "nggv_show_imagebrowser", 10, 2);Look for:
function nggv_show_gallery($out, $gid) {
return $out.nggc_voteForm($gid, $buffer);
}
Add After:
function nggv_show_imagebrowser($out, $gid) {
return $out.nggc_voteForm($gid, $buffer);
}
Now we have given access to the function and can paste the following code into “wp-content/plugins/nextgen-gallery/imagebrowser.php”:
<?php echo nggv_imageVoteForm($image->pid); ?>
Conclusion
I’ve tried to explain this in method in a way you can repeat an extend to suit your needs. By following the same logic and tracing the hooks, you can apply this however you might need.
You’ll want to keep “wp-content/plugins/nextgen-gallery/nggfunctions.php” open as a reference for what hooks are available. You can find hooks by searching for “apply_filters(‘”, it will be the first parameter.
| Print article | This entry was posted by Tyler Mulligan on May 30, 2010 at 4:17 pm, and is filed under The Internet, Web Applications, Web Development, Wordpress. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 1 year ago
Hi Tyler
Could you not just have added the nggv_imageVoteForm() tag to the imagebrowser.php template?
The hook that you copied is only added so that voting is added to galleries without the need for a template call.
Thanks for taking the time to customize the plugin yourself though! You would be amazed at some of the support requests I get from people :)
Shauno
about 1 year ago
nggv_imageVoteForm() didn’t work for me until I added the hook, echo was returning “”.
I can probably think of a few other suggestions for the plugin but I’d rather come to you with a patch. I haven’t had the time to create this as a patch but I wanted to remember what I did and help others so I blogged about it :).
Hreat plugin by the way, the site that I just implemented it on in a 2day code binge is http://www.xonotic.org
about 1 year ago
I didn’t check before writing that comment, so I’m just going to have to believe you :)
Development has stalled a little on my plugins unfortunately. Feel free to drop me a mail or message on the wordpress support forum with any suggestions that you have, and I’ll add them to the ‘todo’ list for when I do feel inspired to work on the plugin again.
about 1 year ago
Well, hopefully I can do enough work on the plugin to submit a patch and save you some trouble :). Definitely the best gallery I’ve found for wordpress, great work.
about 1 year ago
Hello. Show details template for setting nextgen Mystique. Can not set to vote on individual images. Ku yes it is you put in a ‘ pid);?>’ File imagebrowser.php
about 1 year ago
Where exactly do you put in a ‘ pid);?>’ File imagebrowser.php
about 1 year ago
your last code is wrong, it’s not:
pid); ?>
but
pid); ?>
thanks