vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Possible to hand code a link to move a thread to another specific forum? (https://vborg.vbsupport.ru/showthread.php?t=313175)

Jo_RHU 07-23-2014 01:54 PM

Possible to hand code a link to move a thread to another specific forum?
 
Is it possible to create a link that admins/mods can click that will perform the action of moving a thread to a different (specified within the link code) forum, instead of having to use Thread Tools > Move > choose forum

We move threads a lot and if we could code it so that whenever you are viewing a thread in X forum there's a link to move the thread to Y forum, that'd save us a lot of time.

I'm comfortable with the 'if the thread is in X forum' code that would display the link in the right place but no idea what the code would be (if it is actually possible) to have the the next step skipped and go direct to the thread being moved to Y forum.

Thanks for any pointers anyone can give. I have searched for things like 'hand code thread move' but not found any solutions.

kh99 07-23-2014 02:31 PM

I think you can do it with a form. It would be something like:

Code:

<form method="post" action="inlinemod.php?do=domovethread&amp;threadids=TID">
<input type="hidden" name="destforumid" value="FID">
<input type="hidden" name="threadids" value="TID">
<input type="hidden" name="do" value="domovethreads">
</form>

where you'd want to set TID and FID to the threadid and forumid. The threadid would be a available as a variable depending on the template you're putting it in.

You also need to add an input type="submit" or else use some js to submit the form. You can probably make it a link if you want but I'm not really an html person so I don't know how to do it off he top of my head.

blind-eddie 07-23-2014 02:39 PM

Where would this link be on your board?

Jo_RHU 07-23-2014 03:51 PM

Sorry, should have given more info.

Ideally somewhere on the individual thread, so in the SHOWTHREAD template.

--------------- Added [DATE]1406134322[/DATE] at [TIME]1406134322[/TIME] ---------------

Quote:

Originally Posted by kh99 (Post 2507929)
I think you can do it with a form. It would be something like:

Code:

<form method="post" action="inlinemod.php?do=domovethread&amp;threadids="TID">
<input type="hidden" name="destforumid" value="FID">
</form>

where you'd want to set TID and FID to the threadid and forumid. The threadid would be a available as a variable depending on the template you're putting it in.

You also need to add an input type="submit" or else use some js to submit the form. You can probably make it a link if you want but I'm not really an html person so I don't know how to do it off he top of my head.

This looks promising, thanks. I will test it out and report back ASAP!

kh99 07-23-2014 10:23 PM

There's a mistake in the above. Well, at least one mistake, I didn't test it. But I think the do and threadids input fields need to be in the form and not in the action (or in addition to being in the action). In the template for the inline mod menu, they're in both the action and the form, but it looks like the code uses 'p' when it cleans the input.

I fixed the above code.

Jo_RHU 07-24-2014 03:52 PM

Tried the code, thank you :) I got this error:

Quote:

Your submission could not be processed because a security token was missing.
This was the code I used:

PHP Code:

<form method="post" action="inlinemod.php?do=domovethread&amp;threadids=$thread[threadid]">
<
input type="hidden" name="destforumid" value="225">
<
input type="hidden" name="threadid" value="$thread[threadid]">
<
input type="hidden" name="do" value="domovethreads">
<
input type="submit" value="Submit">
</
form>

</if> 

So now I need to work out how to add the security token.

EDIT:

Added security token code copied over from the threadadmin_movethread template as follows:

PHP Code:

<form method="post" action="inlinemod.php?do=domovethread&amp;threadids=$thread[threadid]">
<
input type="hidden" name="s" value="$session[sessionhash]/>
<
input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]/>
<
input type="hidden" name="destforumid" value="225">
<
input type="hidden" name="threadid" value="$thread[threadid]">
<
input type="hidden" name="do" value="domovethreads">
<
input type="submit" value="Submit">
</
form

And now getting this error:

Quote:

You did not select any valid threads
Hmmmmmm.

kh99 07-24-2014 06:22 PM

That's my fault again - the name of the input field should be threadids (with an s). Again, I've fixed my code in the original post.

Jo_RHU 07-25-2014 12:16 PM

Great, it works. Thanks so much :)

For anyone else interested this is the final code (obviously alter the forumid to your needs)

PHP Code:

<form method="post" action="inlinemod.php?do=domovethread&amp;threadids=$thread[threadid]">
<
input type="hidden" name="s" value="$session[sessionhash]/>
<
input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]/>
<
input type="hidden" name="destforumid" value="225">
<
input type="hidden" name="threadids" value="$thread[threadid]">
<
input type="hidden" name="do" value="domovethreads">
<
input type="submit" value="Submit">
</
form


Edited to add:

Another little update, the method above will leave a permanant redirect. I didn't want any redirect so I added an input to handle that:

PHP Code:

<form method="post" action="inlinemod.php?do=domovethread&amp;threadids=$thread[threadid]">
<
input type="hidden" name="s" value="$session[sessionhash]/>
<
input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]/>
<
input type="hidden" name="destforumid" value="225">
<
input type="hidden" name="threadids" value="$thread[threadid]">
<
input type="hidden" name="do" value="domovethreads">
<
input type="hidden" name="redirect" value="none" id="rb_redirect_none" checked="checked" />
<
input type="submit" value="Move thread to X">
</
form

I found the code in the 'threadadmin_movethread' again so if anyone is looking for different redirect options, look there.

Jo_RHU 08-12-2014 09:45 AM

I've found this is conflicting with the inline moderation tools.

Usually when you click the checkbox on a post it highlights it (makes it yellow) then you scroll down to the bottom of the page and the dropdown menu shows you how many posts you've selected, and you can move/delete/merge/etc.

With these buttons added the posts don't get highlighted and it says 0 in the dropdown menu, even if some checkboxes are selected.

I will keep testing and hopefully find a fix but thought I'd post here in case anyone had any suggestions?

Thanks! :)

Lynne 08-12-2014 05:00 PM

You cannot put a <form> within another <form> which is, I am guessing, the problem you are having.

kh99 08-12-2014 08:24 PM

Lynne is probably right. What you might be able to do is put the form somewhere outside the inline mod form, and remove the submit button (the rest of the fields are hidden so it shouldn't show up at all. Then use a js function to set the threadid and submit the form. I haven't tested it at all, but something like:

Code:

<script type="text/javascript">
function move_thread_to_forum(threadid)
{
  if ("move_thread_to_forum" in document.forms)
  {
      var form = document.forms["move_thread_to_forum"];

      form.action += threadid;
      form.elements['threadids'].value = threadid;
      form.submit();
  }
}
</script>
<form name="move_thread_to_forum" method="post" action="inlinemod.php?do=domovethread&amp;threadids=">
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="destforumid" value="225">
<input type="hidden" name="threadids" value="0">
<input type="hidden" name="do" value="domovethreads">
<input type="hidden" name="redirect" value="none" id="rb_redirect_none" checked="checked" />
</form>

and then for the button:
Code:

<button type="button" value="Move thread to X" onClick="move_thread_to_forum($thread[threadid])">
again I didn't try it, could have typos or other problems.

Lynne 08-13-2014 01:50 AM

What page are you putting this on? I have a single click button/form on my site but it is on the thread page. It works just fine because it is located on top of the thread pagination area and thus outside of the moderation form.

kh99 08-13-2014 08:51 AM

Quote:

Originally Posted by Lynne (Post 2511057)
What page are you putting this on? I have a single click button/form on my site but it is on the thread page. It works just fine because it is located on top of the thread pagination area and thus outside of the moderation form.

Oh right, that's a good point. I was thinking it was on a page that had multiple threads, but if it's showthread then maybe it can just be moved.

Jo_RHU 08-13-2014 03:46 PM

Aha! Yes that was it. I hadn't realised I'd placed the code inside the inlinemod form in the SHOWTHREAD template (lesson learned there!)

I've now moved it above the first instance of:

PHP Code:

<if condition="$show['inlinemod']"

and it's working fine. Thanks very much :)


All times are GMT. The time now is 02:16 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01851 seconds
  • Memory Usage 1,792KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (5)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (14)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete