Last Updated: 23 October 2011
With XThreads, we can create a download system. Here is a simple example to do that:
1. First, we will create a file upload for our download system:
Create a Custom Thread Fields with this settings:
- Title: File Upload
- Key: fupload
- Description: Upload a file. You can choose uploading form your computer or from URL.
- Applicable Forums: 'select a forum that we will apply the download system'
- Input Field Type: File
- Valid File Extensions: rar|zip
Modify it as our needs. - Maximum File Size: 1048576
Modify it as our needs. Like the title says, it is a maximum file size (in bytes) that can be uploaded. - Editable by / Required Field?: Everyone (Required)
This Display Format will be replaced by Unviewable Value for not selected usergroup(s) in Viewable by Usergroups setting (new features in the newest version). - Display Format:
HTML Code<form action="{URL}" method="post"> <input type="submit" value="Download Now" /> </form>
To display the Display Format, later, we need put {$GLOBALS['threadfields']['fupload']['value']} variable into our template.
With these additional settings, we can set which usergroup(s) can view the download link. And then we can set what will be displayed for the usergroup(s) which is not allowed to view the download link. Very very useful features. Thank you very much, Yumi
Skip this settings if we didn't want to add the permission for the file: - Viewable by Usergroups: 'Select usergroup(s) which is allowed to view the download link. CTRL + left click to select more than one usergroup'
- Unviewable Value:
This setting will be displayed if at least one usergroup selected in Viewable by Usergroups setting above.
HTML Code<em>You don't have permission to download this file</em>
The text above will replace the download link (in this example, we put it in Display Format) for usergroup(s) which is not selected in the Viewable by Usergroups setting.
2. Now, we will create a description for our download system:
Create a Custom Thread Fields with this settings:
- Title: Description
- Key: fdesc
- Description: Give a short description about the file.
- Applicable Forums: 'select the forum in point 1'
- Input Field Type: Multiline Textbox
- Maximum Text Length: 200
Modify it as our needs. It is a maximum characters for the description. - Editable by / Required Field?: Everyone (Required)
- Display Order: 2
To display the Description, later, we need put {$GLOBALS['threadfields']['fdesc']} variable into our template.
3. Then, we will create a screenshot for our download system:
Create a Custom Thread Fields with this settings:
- Title: Screenshot
- Key: fscr
- Description: Upload a screenshot
- Applicable Forums: 'select the forum in point 1 or 2'
- Input Field Type: File
- Valid File Extensions: gif|png|jpg|jpeg
Modify it as our needs. - Maximum File Size: 1048576
Modify it as our needs. Like the title says, it is a maximum image file size (in bytes) that can be uploaded. - Editable by / Required Field?: Everyone (Required)
- Display Order: 3
- Only accept uploaded images: Yes
- Image Thumbnail Generation: 320x240|640x480
4. Now, we will create categories for our download system:
Create a Custom Thread Fields with this settings:
- Title: Category
- Key: fcat
- Description: Choose a category from the list
- Applicable Forums: 'select the forum in point 1 or 2 or 3'
- Input Field Type: Listbox
- Field Input Height: 1
- Values List:
Code:
Plugin Modification Theme
- Editable by / Required Field?: Everyone (Required)
- Display Order: 4
- Allow Filtering: Yes
- Formatting Map List:
Code:
Plugin{|}<a href="{$forumurl?}filtertf_fcat=Plugin"><span style="color: green;"><strong>Plugin</strong></span></a> Modification{|}<a href="{$forumurl?}filtertf_fcat=Modification"><span style="color: blue;"><strong>Modification</strong></span></a> Theme{|}<a href="{$forumurl?}filtertf_fcat=Theme"><span style="color: red;"><strong>Theme</strong></span></a>
To display this formatting list, we need put {$GLOBALS['threadfields']['fcat']} variable later in our template.
5. Now, XThreads Options in Forum settings (the forum in the settings 1, 2, 3 and 4 above):
- Template Prefix: dld_
- Enable XThreads' Inline Forum Search: Yes
- Override Threads Per Page: 5
Modify it as our needs.
6. Create new templates in Global Template:
- Template Name: dld_forumdisplay_threadlist
- Template Content:
HTML Code<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}">{$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" width="100%" colspan="2"><span class="smalltext"><strong>Sort By: <a href="{$sorturl}&sortby=subject&order=asc">{$lang->thread}</a> {$orderarrow['subject']} | <a href="{$sorturl}&sortby=starter&order=asc">{$lang->author}</a> {$orderarrow['starter']} | <a href="{$sorturl}&sortby=replies&order=desc">{$lang->replies}</a> {$orderarrow['replies']} | <a href="{$sorturl}&sortby=views&order=desc">{$lang->views}</a> {$orderarrow['views']} {$ratingcol} | <a href="{$sorturl}&sortby=lastpost&order=desc">{$lang->lastpost}</a> {$orderarrow['lastpost']}</strong></span></td> {$inlinemodcol} </tr> </table> <br class="clear" /> {$threads}{$nullthreads} <br class="clear" /> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="clear: both;"> <tr> <td class="tfoot" align="right" colspan="{$colspan}"> <form action="forumdisplay.php" method="get"> <input type="hidden" name="fid" value="{$fid}" /> <select name="sortby"> <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> </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" /> {$inline_edit_js}
- Template Name: dld_forumdisplay_threadlist_rating
- Template Content:
HTML Code
| <a href="{$sorturl}&sortby=rating&order=desc">{$lang->rating}</a> {$orderarrow['rating']} <script type="text/javascript" src="jscripts/rating.js?ver=1400"></script> <script type="text/javascript"> <!-- lang.stars = new Array(); lang.stars[1] = "{$lang->one_star}"; lang.stars[2] = "{$lang->two_stars}"; lang.stars[3] = "{$lang->three_stars}"; lang.stars[4] = "{$lang->four_stars}"; lang.stars[5] = "{$lang->five_stars}"; // --> </script>
- Template Name: dld_forumdisplay_thread_rating
- Template Content:
HTML Code
<div align="center" id="rating_table_{$thread['tid']}"> <ul class="star_rating{$not_rated}" id="rating_thread_{$thread['tid']}"> <li style="width: {$thread['width']}%" class="current_rating" id="current_rating_{$thread['tid']}">{$ratingvotesav}</li> </ul> <script type="text/javascript"> <!-- Rating.build_forumdisplay({$thread['tid']}, { width: '{$thread['width']}', extra_class: '{$not_rated}', current_average: '{$ratingvotesav}' }); // --> </script> </div>
- Template Name: dld_forumdisplay_thread
- Template Content:
HTML Code<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="clear: both;"> <tr> <td class="thead" align="center" colspan="{$colspan}"> <div><strong><a href="{$thread['threadlink']}" class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}">{$thread['subject']}</a></strong></div> <div class="author smalltext">{$lang->author}: {$thread['profilelink']}</div> {$rating} </td> </tr> <tr> <td class="{$bgcolor}" width="40%"> <span class="float_left"> <img src="{$theme['imgdir']}/{$folder}.gif" alt="{$folder_label}" title="{$folder_label}" />{$GLOBALS['threadfields']['fupload']['icon']}{$icon}{$prefix}{$gotounread} </span> <span class="float_right"> {$GLOBALS['threadfields']['fcat']} </span> <br class="clear" /> <div align="center"> <table border="0" width="100%"> <tr> <td>File Name</td><td width="1">:</td> <td>{$GLOBALS['threadfields']['fupload']['filename']}</td> </tr> <tr> <td>File Size</td><td>:</td> <td>{$GLOBALS['threadfields']['fupload']['filesize_friendly']}</td> </tr> <tr> <td>Uploaded</td><td>:</td> <td>{$GLOBALS['threadfields']['fupload']['upload_date']}</td> </tr> <tr> <td>Last Update</td><td>:</td> <td>{$GLOBALS['threadfields']['fupload']['update_date']}</td> </tr> <tr> <td>Downloaded</td><td>:</td> <td>{$GLOBALS['threadfields']['fupload']['downloads_friendly']}</td> </tr> </table> </div> <div align="center"> {$GLOBALS['threadfields']['fupload']['value']} </div> </td> <td class="{$bgcolor}" width="60%"> <div align="center"> <a href="{$GLOBALS['threadfields']['fscr']['url']}" target="_blank"><img src="{$GLOBALS['threadfields']['fscr']['thumbs']['320x240']['url']}" alt="{$thread['subject']} Screenshot" title="{$thread['subject']} Screenshot" width="{$GLOBALS['threadfields']['fscr']['thumbs']['320x240']['w']}" height="{$GLOBALS['threadfields']['fscr']['thumbs']['320x240']['h']}" /></a> </div> </td> {$modbit} </tr> <tr> <td class="{$bgcolor}" colspan="{$colspan}"> {$GLOBALS['threadfields']['fdesc']} <br class="clear" /> <span class="float_right smalltext"> <em> {$thread['views']} {$lang->views}, <a href="javascript:MyBB.whoPosted({$thread['tid']});">{$thread['replies']}</a>{$unapproved_posts} {$lang->replies}, <a href="{$thread['lastpostlink']}">{$lang->lastpost}</a>: {$lastposterlink}, {$lastpostdate} {$lastposttime} </em> </span> </td> </tr> </table> <br />
- Template Name: dld_showthread
- Template Content:
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=1400"></script> </head> <body> {$header} {$pollbox} <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;"> <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['subject']}</strong> </div> </td> </tr> <tr> <td class="tcat" colspan="2"> <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="clear: both;"> <tr> <td class="trow1" width="40%"> <table border="0" width="100%"> <tr> <td>File Name</td><td width="1">:</td> <td>{$GLOBALS['threadfields']['fupload']['filename']}</td> </tr> <tr> <td>File Size</td><td>:</td> <td>{$GLOBALS['threadfields']['fupload']['filesize_friendly']}</td> </tr> <tr> <td>Uploaded</td><td>:</td> <td>{$GLOBALS['threadfields']['fupload']['upload_date']}</td> </tr> <tr> <td>Last Update</td><td>:</td> <td>{$GLOBALS['threadfields']['fupload']['update_date']}</td> </tr> <tr> <td>Downloaded</td><td>:</td> <td>{$GLOBALS['threadfields']['fupload']['downloads_friendly']}</td> </tr> </table> </td> <td class="trow1" width="60%"> <div align="center"> <a href="{$GLOBALS['threadfields']['fscr']['url']}" target="_blank"><img src="{$GLOBALS['threadfields']['fscr']['thumbs']['320x240']['url']}" alt="{$thread['subject']} Screenshot" title="{$thread['subject']} Screenshot" width="{$GLOBALS['threadfields']['fscr']['thumbs']['320x240']['w']}" height="{$GLOBALS['threadfields']['fscr']['thumbs']['320x240']['h']}" /></a> </div> </td> </tr> <tr> <td class="trow1" colspan="2"> <span class="float_left smalltext"> {$GLOBALS['threadfields']['fupload']['value']} </span> <span class="float_right smalltext"> <em> Category: {$GLOBALS['threadfields']['fcat']} {$lang->views} {$thread['views']}, {$lang->replies} <a href="javascript:MyBB.whoPosted({$thread['tid']});">{$thread['replies']}</a>{$unapproved_posts} </em> </span> </td> </tr> </table> </td> </tr> {$classic_header} </table> <div id="posts"> {$first_post}{$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;" /> {$footer} </body> </html>
We can add the download system in dld_postbit_first and dld_postbit_first_classic template if we want. But in this example, we add it in dld_showthread template.
- Template Name: dld_forumdisplay_threads_sep
- Template Content:
HTML Code
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="clear: both;"> <tr> <td class="thead" align="center"> <div><strong>Normal Downloads</strong></div> </td> </tr> </table> <br />
- Template Name: dld_forumdisplay_sticky_sep
- Template Content:
HTML Code
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder" style="clear: both;"> <tr> <td class="thead" align="center"> <div><strong>Important Downloads</strong></div> </td> </tr> </table> <br />
Screenshots:
There is no change for the screenshots. All the EDIT above will get the same layout.
1. User create a download thread:
2. User view the post:
3. Thread List:
I'm sorry for my English