03-16-2012, 04:40 AM
Requirement: XThreads
Based on the Thread Descriptions example application, we will try to create a simple Frequently Asked Question (FAQ) forum using XThreads.
Create/edit a forum:
AdminCP -> Forums & Posts -> Forum Management:
Create a Custom Thread Fields:
AdminCP -> Configuration -> Custom Thread Fields
Create new templates in Global Templates:
AdminCP -> Templates & Style -> Templates -> Global Templates
We use language prefix for that (attached). Upload it to our inc/languages/*our language* folder.
Scr:
Threadlist:
[attachment=737]
Shothread:
[attachment=738]
Newthread/Editpost:
[attachment=739]
Live Demo:
http://mybbhacks.zingaburga.com/forumdisplay.php?fid=37
(the Important FAQ are sticky threads, and the General FAQ are normal threads).
Based on the Thread Descriptions example application, we will try to create a simple Frequently Asked Question (FAQ) forum using XThreads.
Create/edit a forum:
AdminCP -> Forums & Posts -> Forum Management:
- Template Prefix: faq_
- Language File Prefix:
Code:
<if THIS_SCRIPT == 'newthread.php' then>faqae_,</if>faq_
- Show first post on every showthread page: Yes
- Enable XThreads' Inline Forum Search: Yes
- Allow Blank Post Message: Yes
Create a Custom Thread Fields:
AdminCP -> Configuration -> Custom Thread Fields
- Title: Answer
Modify it as our needs - Key: faq_answer
- Applicable Forums: select our FAQ forum
- Input Field Type: Multiline Textbox
- Editable by / Required Field?: Moderators
Modify it as our needs (depends on the FAQ forum permissions to create a thread) - Display Parsing: Use MyBB Parser (MyCode)
- MyBB Parser Options: check the following options:
- Allow newlines
- Filter Badwords
- Allow MyCode
Create new templates in Global Templates:
AdminCP -> Templates & Style -> Templates -> Global Templates
- faq_editpost_first
HTML Code<html> <head> <title>{$mybb->settings['bbname']} - {$lang->edit_post}</title> {$headerinclude} <script type="text/javascript" src="jscripts/post.js?ver=1400"></script> </head> <body> {$header} {$preview} {$post_errors} {$attacherror} <form action="editpost.php?pid={$pid}&processed=1" method="post" enctype="multipart/form-data" name="input"> <input type="hidden" name="my_post_key" value="{$mybb->post_code}" /> <div style="width: 60%; margin: auto auto;"> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder"> <tr> <td class="thead" colspan="2"><strong>{$lang->xtfaq_edit_faq}</strong></td> </tr> <tr> <td class="trow2"><strong>{$lang->xtfaq_question}</strong></td> <td class="trow2">{$prefixselect}<input type="text" class="textbox" name="subject" size="40" maxlength="85" value="{$subject}" tabindex="1" /></td> </tr> {$extra_threadfields} <tr style="display: none;"> <td class="trow2" valign="top"><strong>{$lang->your_message}:</strong><br /><div style="text-align: center;">{$smilieinserter}</div></td> <td class="trow2"> <textarea name="message" id="message" rows="20" cols="70" tabindex="3">{$message}</textarea> {$codebuttons} </td> </tr> <tr style="display: none;"> <td class="trow1" valign="top"><strong>{$lang->post_options}</strong></td> <td class="trow1"><span class="smalltext"> <label><input type="checkbox" class="checkbox" name="postoptions[signature]" value="1" tabindex="6"{$postoptionschecked['signature']} /> {$lang->options_sig}</label> {$disablesmilies}</span> </td> </tr> </table> </div> {$attachbox} <br /> <div align="center"><input type="submit" class="button" name="submit" value="{$lang->update_post}" tabindex="3" accesskey="s" /> <input type="submit" class="button" name="previewpost" value="{$lang->preview_post}" tabindex="4" /></div> <input type="hidden" name="action" value="do_editpost" /> <input type="hidden" name="posthash" value="{$posthash}" /> <input type="hidden" name="attachmentaid" value="" /> <input type="hidden" name="attachmentact" value="" /> </form> <br /> <form action="editpost.php" method="post" name="editpost"> <input type="hidden" name="my_post_key" value="{$mybb->post_code}" /> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder"> <tr> <td class="thead" colspan="3"><strong>{$lang->delete_post}</strong></td> </tr> <tr> <td class="trow1" style="white-space: nowrap"><input type="checkbox" class="checkbox" name="delete" value="1" tabindex="9" /> <strong>{$lang->delete_q}</strong></td> <td class="trow1" width="100%">{$lang->delete_1}<br /><span class="smalltext">{$lang->delete_2}</span></td> <td class="trow1"><input type="submit" class="button" name="submit" value="{$lang->delete_now}" tabindex="10" /></td> </tr> </table> <input type="hidden" name="action" value="deletepost" /> <input type="hidden" name="pid" value="{$pid}" /> </form> {$footer} </body> </html>
- faq_forumdisplay_searchforum_inline
HTML Code<form action="forumdisplay.php" method="get"> <span class="smalltext"><strong>{$lang->search_forum}</strong></span> <input type="text" class="textbox" name="search" value="{$searchval}" /> {$gobutton} <input type="hidden" name="fid" value="{$fid}" /> <input type="hidden" name="sortby" value="{$sortby}" /> <input type="hidden" name="order" value="{$sortordernow}" /> <input type="hidden" name="datecut" value="{$datecut}" /> {$xthreads_forum_filter_form} </form>
- faq_forumdisplay_sticky_sep
HTML Code<tr> <td colspan="{$colspan}"><strong>{$lang->xtfaq_ifaq}</strong></td> </tr>
- faq_forumdisplay_thread
HTML Code<tr> {$modbit} <td style="width: 100%;"> <div> <span>{$thread['threadprefix']}<strong>{$lang->xtfaq_q} <a href="{$thread['threadlink']}" class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}" onclick="$('faq_answer_{$thread['tid']}').toggle(); return false;">{$thread['subject']}</a></strong></span> <br class="clear" /> <div id="faq_answer_{$thread['tid']}"> <div class="float_left" style="display: block;"><strong>{$lang->xtfaq_a}</strong></div> <div style="margin-left: 20px;">{$threadfields['faq_answer']}</div> <div class="clear" style="margin: 5px 0px 9px 20px;"> {$gotounread}<a href="{$thread['threadlink']}"><em>{$lang->xtfaq_moreinfo}</em></a> {$thread['multipage']}<br /> <span class="smalltext"> <a href="{$thread['lastpostlink']}">{$lang->lastpost}</a>: {$lastposterlink}{$lang->comma} {$lastpostdate} {$lastposttime} </span> </div> </div> <script type="text/javascript"> <!-- $('faq_answer_{$thread['tid']}').style.display = 'none'; // --> </script> </div> </td> </tr>
- faq_forumdisplay_threadlist
HTML Code<div class="float_right"> {$newthread} </div> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" style="clear: both; width: 80%; margin: auto auto;"> <tr> <td colspan="{$colspan}"> <div style="text-align: center;" class="largetext"> <strong>{$foruminfo['name']}</strong> </div> </td> </tr> {$selectall} {$threads}{$nullthreads} </table> <br class="clear" /> <div style="text-align: center;"> {$multipage} </div> <br class="clear" /> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder"> <tr> {$inlinemodcol} <td class="thead"> <div class="float_right">{$searchforum}</div> {$forumjump} </td> </tr> </table> <div class="float_left" style="margin-top: 4px;"> {$inlinemod} </div> <div class="float_right" style="margin-top: 4px;"> {$newthread} </div> <br style="clear: both;" /> <br /> <div class="smalltext" style="text-align: center;"> {$foruminfo['name']}<br /> Powered by: <a href="http://mybbhacks.zingaburga.com/showthread.php?tid=288">XThreads</a> – <a href="http://mybbhacks.zingaburga.com">MyBB Hacks</a> </div> <br style="clear: both" /> {$inline_edit_js}
- faq_forumdisplay_threads_sep
HTML Code<tr> <td colspan="{$colspan}"><strong>{$lang->xtfaq_gfaq}</strong></td> </tr>
- faq_forumdisplay_thread_modbit
HTML Code<td align="center" style="white-space: nowrap; vertical-align: top"><input type="checkbox" class="checkbox" name="inlinemod_{$multitid}" id="inlinemod_{$multitid}" value="1" {$inlinecheck} /></td>
- faq_newthread
HTML Code<html> <head> <title>{$lang->newthread_in}</title> {$headerinclude} <script type="text/javascript" src="jscripts/post.js?ver=1400"></script> </head> <body> {$header} {$preview} {$thread_errors} {$attacherror} <form action="newthread.php?fid={$fid}&processed=1" method="post" enctype="multipart/form-data" name="input"> <input type="hidden" name="my_post_key" value="{$mybb->post_code}" /> <div style="width: 60%; margin: auto auto;"> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder"> <tr> <td class="thead" colspan="2"><strong>{$lang->xtfaq_new_faq}</strong></td> </tr> <tr> <td class="trow2" width="20%"><strong>{$lang->xtfaq_question}</strong></td> <td class="trow2">{$prefixselect}<input type="text" class="textbox" name="subject" size="49" maxlength="85" value="{$subject}" tabindex="1" /></td> </tr> {$extra_threadfields} <tr style="display: none;"> <td class="trow2" valign="top"><strong>{$lang->your_message}</strong>{$smilieinserter}</td> <td class="trow2"> <textarea name="message" id="message" rows="20" cols="70" tabindex="2">{$message}</textarea> {$codebuttons} {$multiquote_external} </td> </tr> <tr style="display: none;"> <td class="trow1" valign="top"><strong>{$lang->post_options}</strong></td> <td class="trow1"><span class="smalltext"> <label><input type="checkbox" class="checkbox" name="postoptions[signature]" value="1" tabindex="7"{$postoptionschecked['signature']} /> {$lang->options_sig}</label> {$disablesmilies}</span></td> </tr> {$modoptions} {$captcha} </table> </div> {$attachbox} <br /> <div style="text-align:center"><input type="submit" class="button" name="submit" value="{$lang->post_thread}" tabindex="4" accesskey="s" /> <input type="submit" class="button" name="previewpost" value="{$lang->preview_post}" tabindex="5" />{$savedraftbutton}</div> <input type="hidden" name="action" value="do_newthread" /> <input type="hidden" name="posthash" value="{$posthash}" /> <input type="hidden" name="attachmentaid" value="" /> <input type="hidden" name="attachmentact" value="" /> <input type="hidden" name="quoted_ids" value="{$quoted_ids}" /> <input type="hidden" name="tid" value="{$tid}" /> {$editdraftpid} </form> {$forumrules} {$footer} </body> </html>
- faq_postbit_first & faq_postbit_first_classic
HTML Code{$ignore_bit} <a name="pid{$post['pid']}" id="pid{$post['pid']}"></a> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" style="width: 80%; margin: auto auto;{$post_extra_style} {$post_visibility}" id="post_{$post['pid']}"> <tbody> <tr> <td class="post_content {$unapproved_shade}"> <div class="post_body" id="pid_{$post['pid']}"> {$post['posturl']} <div><strong>{$lang->xtfaq_q} {$post['subject']} {$post['subject_extra']}</strong></div> <br class="clear" /> <div class="float_left" style="display: block;"><strong>{$lang->xtfaq_a}</strong></div> <div style="margin-left: 20px;">{$GLOBALS['threadfields']['faq_answer']}</div> {$post['message']} <br class="clear" /> <span id="edited_by_{$post['pid']}" class="float_right">{$post['editedmsg']}</span> <strong>{$post['profilelink']}</strong> {$post['onlinestatus']}<br /> <span class="smalltext">{$post['postdate']}, {$post['posttime']}</span> </div> {$post['attachments']} <div class="post_meta" id="post_meta_{$post['pid']}">{$post['iplogged']}</div> <br class="clear" /> <div class="author_buttons float_left"> {$post['button_email']}{$post['button_pm']}{$post['button_www']}{$post['button_find']}{$post['button_rep']} </div> <div class="post_management_buttons float_right">{$post['button_edit']}{$post['button_quickdelete']}{$post['button_quote']}{$post['button_multiquote']}{$post['button_report']}{$post['button_warn']}{$post['button_reply_pm']}{$post['button_replyall_pm']}{$post['button_forward_pm']}{$post['button_delete_pm']} </div> </td> </tr> </tbody> </table>
- faq_showthread
HTML Code<html> <head> <title>{$thread['subject']}</title> {$headerinclude} <script type="text/javascript"> <!-- var quickdelete_confirm = "{$lang->quickdelete_confirm}"; // --> </script> <script type="text/javascript" src="jscripts/thread.js?ver=1603"></script> </head> <body> {$header} {$pollbox} <br class="clear" /> <div> {$first_post} </div> <br class="clear" /> <div class="float_left">{$multipage}</div> <div class="float_right">{$newreply}</div> {$ratethread} <br class="clear" /> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="clear: both; border-bottom-width: 0; margin-bottom: -7px;"> <tr> <td class="thead" colspan="2"> <div style="float: right;"> <span class="smalltext"><strong><a href="showthread.php?mode=threaded&tid={$tid}&pid={$pid}#pid{$pid}">{$lang->threaded}</a> | <a href="showthread.php?mode=linear&tid={$tid}&pid={$pid}#pid{$pid}">{$lang->linear}</a></strong></span> </div> <div> <strong>{$thread['threadprefix']}{$thread['subject']}</strong> </div> </td> </tr> {$classic_header} </table> <div id="posts"> {$posts} </div> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="border-top-width: 0;"> <tr> <td colspan="2" class="tfoot"> {$search_thread} <div> <strong>« <a href="{$next_oldest_link}">{$lang->next_oldest}</a> | <a href="{$next_newest_link}">{$lang->next_newest}</a> »</strong> </div> </td> </tr> </table> <div class="float_left"> {$multipage} </div> <div style="padding-top: 4px;" class="float_right"> {$newreply} </div> <br style="clear: both;" /> {$quickreply} {$threadexbox} {$similarthreads} <br /> <div class="float_left"> <ul class="thread_tools"> <li class="printable"><a href="printthread.php?tid={$tid}">{$lang->view_printable}</a></li> <li class="sendthread"><a href="sendthread.php?tid={$tid}">{$lang->send_thread}</a></li> <li class="subscription_{$add_remove_subscription}"><a href="usercp2.php?action={$add_remove_subscription}subscription&tid={$tid}&my_post_key={$mybb->post_code}">{$add_remove_subscription_text}</a></li> </ul> </div> <div class="float_right" style="text-align: right;"> {$moderationoptions} {$forumjump} </div> <br style="clear: both;" /> {$usersbrowsing} {$footer} </body> </html>
- faq_showthread_noreplies
HTML Code<div id="xthreads_noreplies"><table border="0" cellspacing="{$GLOBALS['theme']['borderwidth']}" cellpadding="{$GLOBALS['theme']['tablespace']}" class="tborder" style="margin-top: 7px;"><tr><td class="trow2">{$GLOBALS['lang']->xtfaq_noreplies}</td></tr></table></div>
We use language prefix for that (attached). Upload it to our inc/languages/*our language* folder.
Scr:
Threadlist:
[attachment=737]
Shothread:
[attachment=738]
Newthread/Editpost:
[attachment=739]
Live Demo:
http://mybbhacks.zingaburga.com/forumdisplay.php?fid=37
(the Important FAQ are sticky threads, and the General FAQ are normal threads).