We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Post Nominations
Topic Started: Apr 7 2013, 11:59 PM (3,132 Views)
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Code Name: Post Nominations

What the code does: Every post, a button will be added by the Report and Quote buttons, a user can click this button to be redirected to a form where they can nominate the post. The form results are submitted to a forum of your choice. Preview #1, Preview #2

How to use the code: Change FORUM_ID to the forum ID you wish for the results to be deposited to, change IMAGE_URL to the image URL you wish to display in posts for the nominate button, and change OPTION_NAME to a option you wish to add to the Type of Nomination drop down. You can repeat the addOption line to add more options.

How to install the code:

Admin CP Posted Image Board Customization Posted Image Website Maker Posted Image Create New Webpage

Page ID: nominations
Page Title: Post Nominations
Link to this page in the board menu?: No
Page Content:
Code:
 
<form id="nominate">
<table>
<thead>
<tr>
<th colspan="2">Post Nominations</th>
</tr>
</thead>
<tbody>
<tr>
<td class="c_desc">Type of Nomination</td>
<td>
<select name="type">
<option selected="selected">Select one:</option>
</select>
</td>
</tr>
<tr>
<td class="c_desc">Comment</td>
<td><textarea cols="80" rows="10" style="height: 100px" name="comment"></textarea></td>
</tr>
<tr>
<td class="c" colspan="2"><button type="submit">Submit</button></td>
</tr>
</tbody>
</table>
</form>
Admin CP Posted Image Themes Posted Image Board Template Posted Image Below the Board
Code:
 
<script type="text/javascript">
(function ($) {
var imageURL = 'IMAGE_URL';
var forumID = 'FORUM_ID';

$('tr[id*="post-"]').each(function () {
var postURL = $(this).find('td.c_postinfo span.right a').attr('href');
$(this).next('tr').next('tr').next('tr.c_postfoot').find('td.c_footicons span.right').prepend('<a href="' + main_url + 'pages/nominations/?post=' + postURL + '"><img src="' + imageURL + '" alt="Nominate Post" title="Nominate Post" /></a> ');
});

if (location.href.indexOf('/pages/nominations') !== -1) {
function addOption(optionName) {
$('select[name="type"]').append('<option value="' + optionName + '">' + optionName + '</option>');
}

addOption('OPTION_NAME');

var username = $('#top_info strong a').text();
var post = window.location.href.split('?post=')[1];

$('#nominate').submit(function (e) {
var type = $('select[name="type"]').val();
var comment = $('textarea[name="comment"]').val();
e.returnValue = e.preventDefault && e.preventDefault() ? false : false;

$.get(main_url + 'post/?type=1&mode=1&f=' + forumID, function (data) {
var ast = $('input[name="ast"]', data).val();
var xc = $('input[name="xc"]', data).val();
$.post(main_url + 'post/?type=1&mode=1&f=' + forumID, {
mode: 1,
type: 1,
ast: ast,
f: forumID,
xc: xc,
sd: 1,
title: 'Nomination from: ' + username,
post: '[b]Nomination from[/b]: ' + username + ' \n [b]Category[/b]: ' + type + ' \n [b]Link[/b]: ' + post + ' \n [b]Comment[/b]: ' + comment + ''
});
});
alert('Nomination successfully submitted!');
});
}
})(jQuery);
</script>
Edited by Cory, Oct 29 2016, 01:58 AM.
Offline Profile Quote Post Goto Top
 
gmx0
Member
[ * ]
I like it.

Anyone have any handy nomination button images?
Offline Profile Quote Post Goto Top
 
Buddyfrosty
Member
[ * ]
Great code Cory!
Offline Profile Quote Post Goto Top
 
KhaosKarma
Member Avatar
Member
[ *  * ]
Pretty nice code Cory. I'll make good use of this :)

Thanks.
Offline Profile Quote Post Goto Top
 
Sheyney Fox
Member Avatar
Member
[ *  * ]
I can see many uses for this form, is there a way to include the name of the person nominated by any chance?

Another wonderful code Cory, thank you. :wub:
Offline Profile Quote Post Goto Top
 
StarsoftheSpiral
Member
[ * ]
Hmm, nice one. But I'd like this to be like the Like system. Where you like the post and it shows up on that post as "(name of person) likes this post." Except with nominations, I'd like it to say "(name of person) nominates this post."
Offline Profile Quote Post Goto Top
 
Tyler Dream
Member Avatar
Member
[ *  *  *  * ]
Is it possible to add this code to a few topics only? not the whole board?
Actually, I just need the code for one post, not even a whole topic, would this be possible?
Edited by Tyler Dream, Aug 5 2015, 11:59 PM.
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Code:
 
$('tr[id*="post-"]').each(function () {
var postURL = $(this).find('td.c_postinfo span.right a').attr('href');
$(this).next('tr').next('tr').next('tr.c_postfoot').find('td.c_footicons span.right').prepend('<a href="' + main_url + 'pages/nominations/?post=' + postURL + '"><img src="' + imageURL + '" alt="Nominate Post" title="Nominate Post" /></a> ');
});
Change that to this:
Code:
 
var tIDS = ['TOPID_ID', 'TOPID_ID', 'TOPID_ID'];

for (var i = 0; i < tIDS.length; i++) {
if (location.href.indexOf('/topic/' + tIDS[i] + '/') !== -1) {
$('tr[id*="post-"]').each(function() {
var postURL = $(this).find('td.c_postinfo span.right a').attr('href');
$(this).next('tr').next('tr').next('tr.c_postfoot').find('td.c_footicons span.right').prepend('<a href="' + main_url + 'pages/nominations/?post=' + postURL + '"><img src="' + imageURL + '" alt="Nominate Post" title="Nominate Post" /></a> ');
});
}
}
Edit the capitalized text as necessary.
Offline Profile Quote Post Goto Top
 
Tyler Dream
Member Avatar
Member
[ *  *  *  * ]
Thank you :)
At the top of the below the board code, it says forum id, would that be the topic id or?
Edited by Tyler Dream, Aug 6 2015, 12:09 AM.
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
The forumID variable is for the forum ID of the forum you want the nominations to be deposited to.
Offline Profile Quote Post Goto Top
 
Tyler Dream
Member Avatar
Member
[ *  *  *  * ]
I just had a derp moment, thanks :P
Offline Profile Quote Post Goto Top
 
alan131210
Member
[ *  * ]
I get this msg when i post it, how to fix that? lol

Error: You may only have 20,000 characters total in your template.
You have used: 21403 characters.
Error Code: 68014:6038469
Offline Profile Quote Post Goto Top
 
DaPizzaMan
Member Avatar
#TeamSupport

alan131210
Sep 2 2015, 08:59 AM
I get this msg when i post it, how to fix that? lol

Error: You may only have 20,000 characters total in your template.
You have used: 21403 characters.
Error Code: 68014:6038469
You're going to want to host your Javascript externally.
Offline Profile Quote Post Goto Top
 
alan131210
Member
[ *  * ]
^^ how do i do that!?
Offline Profile Quote Post Goto Top
 
Quozzo
Member Avatar
By the blood of Sanguinius!
[ *  *  *  *  * ]
Follow the link.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · ZetaBoards Codes & Modifications · Next Topic »
Add Reply