Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Add custom thread field to thread's subject
xthreads_fan Offline
Junior Member
**
Posts: 3
Joined: Dec 2013
Post: #1
Add custom thread field to thread's subject
Dear team,

firstly, THANKS for this amazing plugin. It made my MyBB so much better!
But now I've met a problem, and I hope you can help me.

In my forum I started a "song" database using XThreads. If you start a new thread you will now have the standard subject field where you can enter a song title, and I also added custom input fields for "singer", "album", "year" and "music video".

So far, everything works nicely.
The problem is the subject of the thread. Is it possible that XThreads somehow adds the field "singer" to the MyBB subject line?

Right now a new topic would have the subject "Paparazzi", but I want it to read "Lady Gaga - Paparazzi", using the input field "singer" first and then using the actual "subject" input which contains the song name.


I hope you can help me!
Thanks!
(This post was last modified: 12-23-2013 06:29 AM by xthreads_fan.)
12-23-2013 06:27 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Add custom thread field to thread's subject
Look at the templates responsible for the thread listing on the forumdisplay page.  You'll see a variable for the thread subject, so it's just a matter of sticking the variable for the desired thread field where you want it.

Do note that this doesn't really change the subject and just how it is displayed.

My Blog
12-23-2013 10:35 PM
Find all posts by this user Quote this message in a reply
xthreads_fan Offline
Junior Member
**
Posts: 3
Joined: Dec 2013
Post: #3
RE: Add custom thread field to thread's subject
Hi ZingaBurga,

thanks for your fast reply! :-)

That's kind of a possibility, but it is more of a workaround :-/
It would mean that I would have to change lots of templates, like forumdisplay_threadlist_thread, and the navigation_bit_active and forumdisplay itself and and...

What I'm looking for is a way to actually ADD some custom field input to the REAL thread subject, so that the subject that's being saved in the database really involves the custom field text.

Is that possible or just too much work?
I thought I just have to add at the end of my template newthread:

Code:
<input type="hidden" name="subject" value="{$GLOBALS['threadfields']['singer']} - {$GLOBALS['threadfields']['songname']}" />

or

Code:
<input type="hidden" name="subject" value="{$tfinput['singer']} - {$tfinput['songname']}" />

...but both don't work...

(This post was last modified: 12-24-2013 01:30 AM by xthreads_fan.)
12-24-2013 01:01 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: Add custom thread field to thread's subject
If you want to hard code the field into the subject, that^ could work, but the problem is that you're relying on the client supplying you the right information (may be okay for your purposes).
XThreads supports doing the reverse, ie bringing the subject into a thread field, but otherwise doesn't really touch MyBB's subject line.  So for what you want, you'll probably need a code edit.

Open newthread.php, and before

PHP Code:
if($mybb->input['action'] == "do_newthread" && $mybb->request_method == "post")

add

PHP Code:
if(in_array($fid, array(1,2,3))) $mybb->input['subject'] = "{$mybb->input['xthreads_singer']} - {$mybb->input['xthreads_songname']}";

(replacing 1,2,3 with the list of applicable forum IDs)

Untested code.


My Blog
12-24-2013 12:45 PM
Find all posts by this user Quote this message in a reply
xthreads_fan Offline
Junior Member
**
Posts: 3
Joined: Dec 2013
Post: #5
RE: Add custom thread field to thread's subject
ZiNgA BuRgA,

you, my Sir, are awesome! But you probably knew this already. Tongue


Your code works PERFECTLY. Thanks so much and a happy start into the new year!
12-27-2013 03:39 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: