inherit
251880
0
Mar 28, 2020 3:41:02 GMT -8
darknight12
Hello there!
5
January 2018
darknight12
|
Post by darknight12 on Mar 27, 2020 12:03:49 GMT -8
Hello there! I'm a total noob at HTML so how do I get to change <h1 id='headertag'>$[thread.subject] $[thread.labels]</h1> to <h1 id='headertag'>$[thread.subject] by $[thread.created_by] $[thread.labels]</h1> ? The way I'm trying to change is by using document.getElementById('headertag').innerText = "$[thread.subject] by $[thread.created_by] $[thread.labels]"; but the problem is that it sets it as a string. So how do I fix it?
|
|
inherit
252032
0
Apr 26, 2024 23:51:41 GMT -8
Retread
Tribbial Pursuit.
5,017
January 2018
retread
|
Post by Retread on Mar 27, 2020 12:21:35 GMT -8
darknight12, $[thread.subject], $[thread.labels], and $[thread.created_by] are Layout Template variables. They aren't valid outside of the layout templates and will be of no use to you when writing a plugin.
If you supply more information regarding what sort of page (home, board, thread, etc) your script is targeting, and what your ultimate goal is, one of the more experienced coders might be able to assist you in extracting the necessary information from the page.
|
|
inherit
251880
0
Mar 28, 2020 3:41:02 GMT -8
darknight12
Hello there!
5
January 2018
darknight12
|
Post by darknight12 on Mar 27, 2020 12:31:54 GMT -8
Oh wow, I'm actually trying to edit one of your plugins Haha.(https://www.proboards.com/library/plugins/item/2003) So what I'm trying to do is that for whichever board has the plugin active, I would like to have the thread's author added to the title of the thread. Eg: Book by username
|
|
inherit
252032
0
Apr 26, 2024 23:51:41 GMT -8
Retread
Tribbial Pursuit.
5,017
January 2018
retread
|
Post by Retread on Mar 27, 2020 14:30:59 GMT -8
Oh wow, I'm actually trying to edit one of your plugins Haha.(https://www.proboards.com/library/plugins/item/2003) So what I'm trying to do is that for whichever board has the plugin active, I would like to have the thread's author added to the title of the thread.Eg: Book by username Okay, this is a bit beyond my skillset, so I'll tag a couple of coders who might have the time and interest to help. elli , Chris The username is already in the mini-profile of the first post, so maybe that can be grabbed before the mini-profile is removed, then appended to the thread title in the title bar. idk. Or maybe it will be necessary to use the proboards.data for the page or thread to get the user ID? Anyway, here is the JavaScript component of that plugin: $(document).ready(function() {
var settings = pb.plugin.get('remove_mp_on_first_post').settings;
// Selection from Threads Autoform if (settings.thread_id_numbers.length) { for (var z = 0; z < settings.thread_id_numbers.length; z++) { if (proboards.data('thread_id') == parseInt(settings.thread_id_numbers[z].thread_id)) { $('.posts .post.first .left-panel').css('display', 'none'); if (settings.thread_id_numbers[z].xsig == 1){ $('.posts .post.first .foot .signature').css('display', 'none'); } if (settings.thread_id_numbers[z].xedit == 1){ $('.posts .post.first .foot .edited_by').css('display', 'none'); } if (settings.thread_id_numbers[z].xquote == 1){ $('.posts .post.first .button.quote-button').css('display', 'none'); } }}; } // Selection from Boards Autoform if (settings.board_id_numbers.length) { for (var z = 0; z < settings.board_id_numbers.length; z++) { if (proboards.data('board_id') == parseInt(settings.board_id_numbers[z].board_id)) { $('.posts .post.first .left-panel').css('display', 'none'); if (settings.board_id_numbers[z].xsig == 1){ $('.posts .post.first .foot .signature').css('display', 'none'); } if (settings.board_id_numbers[z].xedit == 1){ $('.posts .post.first .foot .edited_by').css('display', 'none'); } if (settings.board_id_numbers[z].xquote == 1){ $('.posts .post.first .button.quote-button').css('display', 'none'); } }}; } });
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,849
January 2015
msg
|
Post by Lynx on Mar 27, 2020 14:43:18 GMT -8
pb.data('page').thread.subject
will return a thread's subject, but I'd recommend checks to make sure it's present:
if(pb.data('page') && pb.data('page').thread && pb.data('page').thread.subject) {
The user's ID of who created the thread can be grabbed with
pb.data('page').thread.created_by
Note that it's the OP's ID that's returned and not the username.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Mar 27, 2020 21:24:41 GMT -8
This will likely need to be tweaked because I saw no posted forum url where the theme in question could be inspected. Try replacing the javascript in the plugin that was posted by Retread with the following $(document).ready(function() {
var settings = pb.plugin.get('remove_mp_on_first_post').settings;
// Selection from Threads Autoform if (settings.thread_id_numbers.length) { for (var z = 0; z < settings.thread_id_numbers.length; z++) { if (proboards.data('thread_id') == parseInt(settings.thread_id_numbers[z].thread_id)) { $('.posts .post.first .left-panel').css('display', 'none') .each(addHeaderTag); if (settings.thread_id_numbers[z].xsig == 1){ $('.posts .post.first .foot .signature').css('display', 'none'); } if (settings.thread_id_numbers[z].xedit == 1){ $('.posts .post.first .foot .edited_by').css('display', 'none'); } if (settings.thread_id_numbers[z].xquote == 1){ $('.posts .post.first .button.quote-button').css('display', 'none'); } }}; } // Selection from Boards Autoform if (settings.board_id_numbers.length) { for (var z = 0; z < settings.board_id_numbers.length; z++) { if (proboards.data('board_id') == parseInt(settings.board_id_numbers[z].board_id)) { $('.posts .post.first .left-panel').css('display', 'none') .each(addHeaderTag) if (settings.board_id_numbers[z].xsig == 1){ $('.posts .post.first .foot .signature').css('display', 'none'); } if (settings.board_id_numbers[z].xedit == 1){ $('.posts .post.first .foot .edited_by').css('display', 'none'); } if (settings.board_id_numbers[z].xquote == 1){ $('.posts .post.first .button.quote-button').css('display', 'none'); } }}; } function addHeaderTag(){ $('#headertag').html(function(p){ return (p=pb.data('page')) ? (function(){ return $('<a></a>',{href:p.thread.url, class: 'thread-link'}).append(p.thread.subject)[0].outerHTML + " by " + ($('.posts .post.first .left-panel').find('.user-link,[itemtype="http://schema.org/Person"]')[0]||$('<a class="user-link">Unknown</a>')[0]).outerHTML + " [" + (pb.data('labels_applied')||[]).map(function(a){return '<a href="/board/'+a.board_id+'/'+p.board.name+'?filters[]=label_id:eq:'+a.id+'" class="ui-label label-'+a.id+' label-board-'+p.board.id+'" style="border-color:#'+a.color+';color:#'+a.color+'">'+a.name+'</a>'})+"]" })() :"" }) } });
|
|
inherit
251880
0
Mar 28, 2020 3:41:02 GMT -8
darknight12
Hello there!
5
January 2018
darknight12
|
Post by darknight12 on Mar 28, 2020 1:48:10 GMT -8
This will likely need to be tweaked because I saw no posted forum url where the theme in question could be inspected. Try replacing the javascript in the plugin that was posted by Retread with the following $(document).ready(function() {
var settings = pb.plugin.get('remove_mp_on_first_post').settings;
// Selection from Threads Autoform if (settings.thread_id_numbers.length) { for (var z = 0; z < settings.thread_id_numbers.length; z++) { if (proboards.data('thread_id') == parseInt(settings.thread_id_numbers[z].thread_id)) { $('.posts .post.first .left-panel').css('display', 'none') .each(addHeaderTag); if (settings.thread_id_numbers[z].xsig == 1){ $('.posts .post.first .foot .signature').css('display', 'none'); } if (settings.thread_id_numbers[z].xedit == 1){ $('.posts .post.first .foot .edited_by').css('display', 'none'); } if (settings.thread_id_numbers[z].xquote == 1){ $('.posts .post.first .button.quote-button').css('display', 'none'); } }}; } // Selection from Boards Autoform if (settings.board_id_numbers.length) { for (var z = 0; z < settings.board_id_numbers.length; z++) { if (proboards.data('board_id') == parseInt(settings.board_id_numbers[z].board_id)) { $('.posts .post.first .left-panel').css('display', 'none') .each(addHeaderTag) if (settings.board_id_numbers[z].xsig == 1){ $('.posts .post.first .foot .signature').css('display', 'none'); } if (settings.board_id_numbers[z].xedit == 1){ $('.posts .post.first .foot .edited_by').css('display', 'none'); } if (settings.board_id_numbers[z].xquote == 1){ $('.posts .post.first .button.quote-button').css('display', 'none'); } }}; } function addHeaderTag(){ $('#headertag').html(function(p){ return (p=pb.data('page')) ? (function(){ return $('<a></a>',{href:p.thread.url, class: 'thread-link'}).append(p.thread.subject)[0].outerHTML + " by " + ($('.posts .post.first .left-panel').find('.user-link,[itemtype="http://schema.org/Person"]')[0]||$('<a class="user-link">Unknown</a>')[0]).outerHTML + " [" + (pb.data('labels_applied')||[]).map(function(a){return '<a href="/board/'+a.board_id+'/'+p.board.name+'?filters[]=label_id:eq:'+a.id+'" class="ui-label label-'+a.id+' label-board-'+p.board.id+'" style="border-color:#'+a.color+';color:#'+a.color+'">'+a.name+'</a>'})+"]" })() :"" }) } }); This is the test site which we are trying it on: greenrentest.boards.net/thread/2/omg-epic-new-mod Don't mind the memes
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Mar 28, 2020 11:49:39 GMT -8
Looks like you've made your necessary edits and have things well in hand?
|
|