07-23-2011, 07:24 AM
Requirement: XThreads
We will try to create a simple MyCodes Database using XThreads.
Create or edit a forum with these settings:
Create a Custom Thread Fields with these settings:
AdminCP -> Configuration -> Custom Thread Fields
Create new templates in Global Template.
Admin CP -> Templates & Style -> Templates -> Global Templates:
That's our simple MyCodes Database
Additional Info:
Screenshoot:
We will try to create a simple MyCodes Database using XThreads.
Create or edit a forum with these settings:
- Template Prefix: mcde_
- Enable XThreads' Inline Forum Search: Yes
- Allow Blank Post Message: Yes
- Custom WOL Text:
- Forum Display:
HTML Code
Viewing <a href="{1}">{2}</a>
- New Thread:
HTML Code
Submitting a new MyCode
- New Reply:
HTML Code
Commenting on <a href="{1}">{2}</a> MyCode
- Show Thread:
HTML Code
Reading<a href="{1}">{2}</a> MyCode
- Forum Display:
Create a Custom Thread Fields with these settings:
AdminCP -> Configuration -> Custom Thread Fields
- Textbox for Short Description:
- Title: Short Description
- Key: mcdedesc
- Applicable Forums: 'select our MyCodes Database forum'
- Input Field Type: Textbox
- Editable by / Required Field?: Everyone (required)
- Display Order: 1
- Textbox for Regular Expression:
- Title: Regular Expression
- Key: mcdere
- Applicable Forums: 'select our MyCodes Database forum'
- Input Field Type: Textbox
- Editable by / Required Field?: Everyone (required)
- Display Order: 2
- Display Format:
HTML Code<pre class="codeblock" id="mcdere_{$thread['tid']}" style="float: left; margin: 3px; width: 600px; height: 20px; overflow: auto;">{VALUE}</pre> <input type="button" value="Select" onClick="window.selectNode(document.getElementById('mcdere_{$thread['tid']}'));">
- Multiline Textbox for Replacement:
- Title: Replacement
- Key: mcderep
- Applicable Forums: 'select our MyCodes Database forum'
- Input Field Type: Multiline Textbox
- Editable by / Required Field?: Everyone (required)
- Display Order: 3
- Display Format:
HTML Code<pre class="codeblock" id="mcderep_{$thread['tid']}" style="float: left; margin: 3px; width: 600px; height: 50px; overflow: auto;">{VALUE}</pre> <input type="button" value="Select" onClick="window.selectNode(document.getElementById('mcderep_{$thread['tid']}'));">
- Multiline Textbox for Example:
- Title: Example
- Key: mcdeex
- Applicable Forums: 'select our MyCodes Database forum'
- Input Field Type: Multiline Textbox
- Editable by / Required Field?: Everyone (required)
- Display Parsing: Use MyBB Parser
- MyBB Parser Options: Check all except the Allow HTML.
- MyBB Parser Options: Check all except the Allow HTML.
- Display Order: 4
- Display Format:
Code:<func nl2br><func htmlspecialchars_uni>{RAWVALUE}</func></func> <setvar result>{VALUE}</setvar> <setvar result_text>'Result'</setvar>
Create new templates in Global Template.
Admin CP -> Templates & Style -> Templates -> Global Templates:
- mcde_forumdisplay_thread
HTML Code<tr> <td class="{$bgcolor}{$thread_type_class}" colspan="2"> {$attachment_count} <div> <span>{$prefix} {$gotounread}{$thread['threadprefix']}<a href="{$thread['threadlink']}" class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}">{$thread['subject']}</a>{$thread['multipage']}</span> <div class="smalltext">{$GLOBALS['threadfields']['mcdedesc']}</div> <div class="author smalltext">{$thread['profilelink']}</div> </div> </td> <td align="center" class="{$bgcolor}{$thread_type_class}"><a href="javascript:MyBB.whoPosted({$thread['tid']});">{$thread['replies']}</a>{$unapproved_posts}</td> <td align="center" class="{$bgcolor}{$thread_type_class}">{$thread['views']}</td> {$rating} <td class="{$bgcolor}{$thread_type_class}" style="white-space: nowrap; text-align: right;"> <span class="lastpost smalltext">{$lastpostdate} {$lastposttime}<br /> <a href="{$thread['lastpostlink']}">{$lang->lastpost}</a>: {$lastposterlink}</span> </td> {$modbit} </tr> <tr> <td class="{$bgcolor}{$thread_type_class}" colspan="{$colspan}"> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="border: 0px;"> <tr> <td class="{$bgcolor}{$thread_type_class}" style="width: 1%; white-space: nowrap;"> <div class="smalltext">{$GLOBALS['threadfields_x']['mcdere']['title']}</div> </td> <td class="{$bgcolor}{$thread_type_class}">{$GLOBALS['threadfields']['mcdere']}</td> </tr> <tr> <td class="{$bgcolor}{$thread_type_class}" style="white-space: nowrap;"> <div class="smalltext">{$GLOBALS['threadfields_x']['mcderep']['title']}</div> </td> <td class="{$bgcolor}{$thread_type_class}">{$GLOBALS['threadfields']['mcderep']}</td> </tr> <tr> <td class="{$bgcolor}{$thread_type_class}" style="white-space: nowrap;"> <div class="smalltext">{$GLOBALS['threadfields_x']['mcdeex']['title']}</div> </td> <td class="{$bgcolor}{$thread_type_class}"><div class="post_body">{$GLOBALS['threadfields']['mcdeex']}</div></td> </tr> <tr> <td class="{$bgcolor}{$thread_type_class}" style="white-space: nowrap;"> <div class="smalltext">{$GLOBALS['tplvars']['result_text']}</div> </td> <td class="{$bgcolor}{$thread_type_class}"><div class="post_body">{$GLOBALS['tplvars']['result']}</div></td> </tr> </table> </td> </tr>
- mcde_forumdisplay_threadlist
HTML Code<script type="text/javascript"> function selectNode (node){ var selection, range, doc, win; if ((doc = node.ownerDocument) && (win = doc.defaultView) && typeof win.getSelection != 'undefined' && typeof doc.createRange != 'undefined' && (selection = window.getSelection()) && typeof selection.removeAllRanges != 'undefined') { range = doc.createRange(); range.selectNode(node); selection.removeAllRanges(); selection.addRange(range); } else if (document.body && typeof document.body.createTextRange != 'undefined' && (range = document.body.createTextRange())){ range.moveToElementText(node); range.select(); } } </script> <div class="float_left"> {$multipage} </div> <div class="float_right"> {$newthread} </div> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="clear: both;"> <tr> <td class="thead" colspan="{$colspan}"> <div style="float: right;"> <span class="smalltext"><strong><a href="misc.php?action=markread&fid={$fid}{$post_code_string}">{$lang->markforum_read}</a> | <a href="usercp2.php?action={$add_remove_subscription}subscription&type=forum&fid={$fid}&my_post_key={$mybb->post_code}">{$add_remove_subscription_text}</a>{$clearstoredpass}</strong></span> </div> <div> <strong>{$foruminfo['name']}</strong> </div> </td> </tr> <tr> <td class="tcat" colspan="2" width="66%"><span class="smalltext"><strong><a href="{$sorturl}&sortby=subject&order=asc">{$lang->thread}</a> {$orderarrow['subject']} / <a href="{$sorturl}&sortby=starter&order=asc">{$lang->author}</a> {$orderarrow['starter']}</strong></span></td> <td class="tcat" align="center" width="7%"><span class="smalltext"><strong><a href="{$sorturl}&sortby=replies&order=desc">{$lang->replies}</a> {$orderarrow['replies']}</strong></span></td> <td class="tcat" align="center" width="7%"><span class="smalltext"><strong><a href="{$sorturl}&sortby=views&order=desc">{$lang->views}</a> {$orderarrow['views']}</strong></span></td> {$ratingcol} <td class="tcat" align="right" width="20%"><span class="smalltext"><strong><a href="{$sorturl}&sortby=lastpost&order=desc">{$lang->lastpost}</a> {$orderarrow['lastpost']}</strong></span></td> {$inlinemodcol} </tr> {$selectall} {$announcementlist} {$threads}{$nullthreads} <tr> <td class="tfoot" align="right" colspan="{$colspan}"> <form action="forumdisplay.php" method="get"> <input type="hidden" name="selectall" value="{$allselected}" /> <input type="hidden" name="fid" value="{$fid}" /> <select name="sortby"> {$sort_by_prefix}<option value="subject" {$sortsel['subject']}>{$lang->sort_by_subject}</option> <option value="lastpost" {$sortsel['lastpost']}>{$lang->sort_by_lastpost}</option> <option value="starter" {$sortsel['starter']}>{$lang->sort_by_starter}</option> <option value="started" {$sortsel['started']}>{$lang->sort_by_started}</option> {$ratingsort} <option value="replies" {$sortsel['replies']}>{$lang->sort_by_replies}</option> <option value="views" {$sortsel['views']}>{$lang->sort_by_views}</option> <option value="icon" {$sortsel['icon']}>{$lang->sort_by_icon}</option> <option value="lastposter" {$sortsel['lastposter']}>{$lang->sort_by_lastposter}</option> <option value="attachmentcount" {$sortsel['attachmentcount']}>{$lang->sort_by_attachmentcount}</option> {$xthreads_extra_sorting} </select> <select name="order"> <option value="asc" {$ordersel['asc']}>{$lang->sort_order_asc}</option> <option value="desc" {$ordersel['desc']}>{$lang->sort_order_desc}</option> </select> <select name="datecut"> <option value="1" {$datecutsel['1']}>{$lang->datelimit_1day}</option> <option value="5" {$datecutsel['5']}>{$lang->datelimit_5days}</option> <option value="10" {$datecutsel['10']}>{$lang->datelimit_10days}</option> <option value="20" {$datecutsel['20']}>{$lang->datelimit_20days}</option> <option value="50" {$datecutsel['50']}>{$lang->datelimit_50days}</option> <option value="75" {$datecutsel['75']}>{$lang->datelimit_75days}</option> <option value="100" {$datecutsel['100']}>{$lang->datelimit_100days}</option> <option value="365" {$datecutsel['365']}>{$lang->datelimit_lastyear}</option> <option value="9999" {$datecutsel['9999']}>{$lang->datelimit_beginning}</option> </select> {$gobutton} </form> </td> </tr> </table> <div class="float_left"> {$multipage} </div> <div class="float_right" style="margin-top: 4px;"> {$newthread} </div> <br style="clear: both;" /> <br /> <div class="float_left"> <div class="float_left"> <dl class="thread_legend smalltext"> <dd><img src="{$theme['imgdir']}/newfolder.gif" alt="{$lang->new_thread}" title="{$lang->new_thread}" /> {$lang->new_thread}</dd> <dd><img src="{$theme['imgdir']}/newhotfolder.gif" alt="{$lang->new_hot_thread}" title="{$lang->new_hot_thread}" /> {$lang->new_hot_thread}</dd> <dd><img src="{$theme['imgdir']}/hotfolder.gif" alt="{$lang->hot_thread}" title="{$lang->hot_thread}" /> {$lang->hot_thread}</dd> </dl> </div> <div class="float_left"> <dl class="thread_legend smalltext"> <dd><img src="{$theme['imgdir']}/folder.gif" alt="{$lang->no_new_thread}" title="{$lang->no_new_thread}" /> {$lang->no_new_thread}</dd> <dd><img src="{$theme['imgdir']}/dot_folder.gif" alt="{$lang->posts_by_you}" title="{$lang->posts_by_you}" /> {$lang->posts_by_you}</dd> <dd><img src="{$theme['imgdir']}/lockfolder.gif" alt="{$lang->locked_thread}" title="{$lang->locked_thread}" /> {$lang->locked_thread}</dd> </dl> </div> <br style="clear: both" /> </div> <div class="float_right" style="text-align: right;"> {$inlinemod} {$searchforum} {$forumjump} </div> <br style="clear: both" /> <div class="smalltext" 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> {$inline_edit_js}
- mcde_postbit_first
HTML Code<script type="text/javascript"> function selectNode (node){ var selection, range, doc, win; if ((doc = node.ownerDocument) && (win = doc.defaultView) && typeof win.getSelection != 'undefined' && typeof doc.createRange != 'undefined' && (selection = window.getSelection()) && typeof selection.removeAllRanges != 'undefined') { range = doc.createRange(); range.selectNode(node); selection.removeAllRanges(); selection.addRange(range); } else if (document.body && typeof document.body.createTextRange != 'undefined' && (range = document.body.createTextRange())){ range.moveToElementText(node); range.select(); } } </script> {$ignore_bit} <a name="pid{$post['pid']}" id="pid{$post['pid']}"></a> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="{$post_extra_style} {$post_visibility}" id="post_{$post['pid']}"> <tbody> <tr> <td class="tcat"> <div class="float_left smalltext"> {$post['postdate']}, {$post['posttime']} <span id="edited_by_{$post['pid']}">{$post['editedmsg']}</span> </div> {$post['posturl']} </td> </tr> <tr> <td class="trow1 {$unapproved_shade}"> <table cellspacing="0" cellpadding="0" border="0" style="width: 100%;"> <tr> <td class="post_avatar" width="1" style="{$post['avatar_padding']}"> {$post['useravatar']} </td> <td class="post_author"> <strong><span class="largetext">{$post['profilelink']}</span></strong> {$post['onlinestatus']}<br /> <span class="smalltext"> {$post['usertitle']}<br /> {$post['userstars']} {$post['groupimage']} </span> </td> <td class="smalltext post_author_info" width="165"> {$post['user_details']} </td> </tr> </table> </td> </tr> <tr> <td class="trow2 post_content {$unapproved_shade}"> <div class="clear"> <strong>{$post['subject']} {$post['subject_extra']}</strong><br /> {$GLOBALS['threadfields']['mcdedesc']} </div> <br class="clear" /> <div class="clear"> <strong>{$GLOBALS['threadfields_x']['mcdere']['title']}</strong> <br class="clear" /> {$GLOBALS['threadfields']['mcdere']} </div> <br class="clear" /> <div class="clear"> <strong>{$GLOBALS['threadfields_x']['mcderep']['title']}</strong> <br class="clear" /> {$GLOBALS['threadfields']['mcderep']} </div> <br class="clear" /> <br /> <div class="clear"> <strong>{$GLOBALS['threadfields_x']['mcdeex']['title']}</strong> <br class="clear" /> {$GLOBALS['threadfields']['mcdeex']} </div> <br class="clear" /> <div class="clear"> <strong>{$GLOBALS['tplvars']['result_text']}</strong> <br class="clear" /> {$GLOBALS['tplvars']['result']} </div> <br class="clear" /> <div class="post_body" id="pid_{$post['pid']}"> {$post['message']} </div> {$post['attachments']} {$post['signature']} <div class="post_meta" id="post_meta_{$post['pid']}"> {$post['iplogged']} </div> </td> </tr> <tr> <td class="trow1 post_buttons {$unapproved_shade}"> <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>
- mcde_postbit_first_classic
HTML Code<script type="text/javascript"> function selectNode (node){ var selection, range, doc, win; if ((doc = node.ownerDocument) && (win = doc.defaultView) && typeof win.getSelection != 'undefined' && typeof doc.createRange != 'undefined' && (selection = window.getSelection()) && typeof selection.removeAllRanges != 'undefined') { range = doc.createRange(); range.selectNode(node); selection.removeAllRanges(); selection.addRange(range); } else if (document.body && typeof document.body.createTextRange != 'undefined' && (range = document.body.createTextRange())){ range.moveToElementText(node); range.select(); } } </script> {$ignore_bit} <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="{$post_extra_style} {$post_visibility}" id="post_{$post['pid']}"> <tr> <td class="{$altbg}" width="15%" valign="top" style="white-space: nowrap; text-align: center;"><a name="pid{$post['pid']}" id="pid{$post['pid']}"></a> <strong><span class="largetext">{$post['profilelink']}</span></strong> {$post['onlinestatus']}<br /> <span class="smalltext"> {$post['usertitle']}<br /> {$post['userstars']} {$post['groupimage']} {$post['useravatar']}<br /> {$post['user_details']} </span> </td> <td class="{$altbg}" valign="top"> <table width="100%"> <tr><td> <div class="clear"> <strong>{$post['subject']} {$post['subject_extra']}</strong><br /> {$GLOBALS['threadfields']['mcdedesc']} </div> <br class="clear" /> <div class="clear"> <strong>{$GLOBALS['threadfields_x']['mcdere']['title']}</strong> <br class="clear" /> {$GLOBALS['threadfields']['mcdere']} </div> <br class="clear" /> <div class="clear"> <strong>{$GLOBALS['threadfields_x']['mcderep']['title']}</strong> <br class="clear" /> {$GLOBALS['threadfields']['mcderep']} </div> <br class="clear" /> <br /> <div class="clear"> <strong>{$GLOBALS['threadfields_x']['mcdeex']['title']}</strong> <br class="clear" /> {$GLOBALS['threadfields']['mcdeex']} </div> <br class="clear" /> <div class="clear"> <strong>{$GLOBALS['tplvars']['result_text']}</strong> <br class="clear" /> {$GLOBALS['tplvars']['result']} </div> <br class="clear" /> <div id="pid_{$post['pid']}" style="padding: 5px 0 5px 0;"> {$post['message']} </div> {$post['attachments']} {$post['signature']} <div style="text-align: right; vertical-align: bottom;" id="post_meta_{$post['pid']}"> <div id="edited_by_{$post['pid']}">{$post['editedmsg']}</div> {$post['iplogged']} </div> </td></tr> </table> </td> </tr> <tr> <td class="{$altbg}" style="white-space: nowrap; text-align: center; vertical-align: middle;"><span class="smalltext">{$post['postdate']} {$post['posttime']}</span></td> <td class="{$altbg}" style="vertical-align: middle;"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr valign="bottom"> <td align="left" ><span class="smalltext">{$post['button_email']}{$post['button_pm']}{$post['button_www']}{$post['button_find']}{$post['button_rep']}</span></td> <td align="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']}</td> </tr> </table> </td> </tr> </table>
That's our simple MyCodes Database
Additional Info:
- The MyCode Result will be "generated automatically" if we have the MyCode installed on our forum.
- If we don't want the Regular Expression and the Replacement to be selectable, remove the javascript and the button from its Display Format. I get the javascript from the internet. I don't have any knowledge about it
- The templates above based on MyBB 1.6.3
- Please tell me if there is something wrong with the example application above. I'm still learning.
Screenshoot:
- Postbit - Postbit Classic
[attachment=563] [attachment=562] - Preview Post
[attachment=564] - Thread List
[attachment=565]