MyBB Hacks

Full Version: MyBB Hacks download system
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I know RateU designed an excellent download system using xthreads, but I need a simpler one.
I'd love to have the same setup that zinga uses for the plugins forum.
Any help on this?
I'm not quite sure what custom thread fields you need for your download section besides the file upload and the description. This is a simple example for that. Only use file upload and description. Modify it if you have other custom thread fields.

  1. File fields for file upload:
    • Title: File Upload
    • Key: mhdld_file
    • Applicable Forums: select download section
    • Input Field Type : File
    • Valid File Extensions : rar|zip|pdf
      Modify it as our needs. It is the file extension that can be uploaded.
    • Maximum File Size : 204800
      Modify it as our needs. It is the maximum file size can be uploaded (in bytes).
    • Editable by / Required Field? : Everyone (required)
      Modify it as our needs. We can choose which usergroup can upload file.
    • Display Format :

      HTML Code
      <strong>Download: <a href="{URL}">{FILENAME}</a></strong><br />

      If the file not available for all usergroups, we can select which usergroup can download the file. Select the usergroup in the Viewable by Usergroups setting, then specify what to be displayed for usergroup who can't download the file in Unviewable Value text area.

  2. Textbox fields for description:
    • Title: Description
    • Key: mhdld_desc
    • Applicable Forums : select the download forum
    • Editable by / Required Field? : Everyone (required)
      Modify it as our needs.
    • Display Parsing : We can select Use MyBB Parser (MyCode) if we want to use BBCode in the description.
    • Display Format :

      HTML Code
      <div class="smalltext">{VALUE}</div>



Then, set our download forum setting like this:
  • Template Prefix: mhdld_
  • Show first post on every showthread page: Yes

Then create new templates in Global Templates:
(The templates bellow based on MyBB 1.4)
  1. mhdld_forumdisplay_thread

    HTML Code
    <tr>
    	<td align="center" class="{$bgcolor}" width="2%"><img src="{$theme['imgdir']}/{$folder}.gif" alt="{$folder_label}" title="{$folder_label}" /></td>
    	<td align="center" class="{$bgcolor}" width="2%">{$icon}</td>
    	<td class="{$bgcolor}">
    		{$attachment_count}
    		<div>
    			<span>{$prefix} {$gotounread}<a href="{$thread['threadlink']}" class="{$inline_edit_class} {$new_class}" id="tid_{$inline_edit_tid}">{$thread['subject']}</a>{$thread['multipage']}</span>
    			{$GLOBALS['threadfields']['mhdld_desc']}
    		</div>
    	</td>
    	<td align="center" class="{$bgcolor}"><a href="javascript:MyBB.whoPosted({$thread['tid']});">{$thread['replies']}</a>{$unapproved_posts}</td>
    	<td align="center" class="{$bgcolor}">{$GLOBALS['threadfields']['mhdld_file']['downloads_friendly']}</td>
    	{$rating}
    	<td class="{$bgcolor}" 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>

  2. mhdld_forumdisplay_threadlist

    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&amp;fid={$fid}">{$lang->markforum_read}</a> | <a href="usercp2.php?action={$add_remove_subscription}subscription&amp;type=forum&amp;fid={$fid}&amp;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="3" width="66%"><span class="smalltext"><strong><a href="{$sorturl}&amp;sortby=subject&amp;order=asc">{$lang->thread}</a> {$orderarrow['subject']} / <a href="{$sorturl}&amp;sortby=starter&amp;order=asc">{$lang->author}</a> {$orderarrow['starter']}</strong></span></td>
    		<td class="tcat" align="center" width="7%"><span class="smalltext"><strong><a href="{$sorturl}&amp;sortby=replies&amp;order=desc">{$lang->replies}</a> {$orderarrow['replies']}</strong></span></td>
    		<td class="tcat" align="center" width="7%"><span class="smalltext"><strong>Downloads</strong></span></td>
    		{$ratingcol}
    		<td class="tcat" align="right" width="20%"><span class="smalltext"><strong><a href="{$sorturl}&amp;sortby=lastpost&amp;order=desc">{$lang->lastpost}</a> {$orderarrow['lastpost']}</strong></span></td>
    		{$inlinemodcol}
    	</tr>
    	{$announcementlist}
    	{$threads}{$nullthreads}
    	<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}

  3. mhdld_postbit_first and mhdld_postbit_first_classic

    HTML Code
    {$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}" valign="top"><a name="pid{$post['pid']}" id="pid{$post['pid']}"></a>
    			<table width="100%">
    				<tr>
    					<td>
    						{$post['posturl']}
    						<div id="pid_{$post['pid']}" style="padding: 5px 0 5px 0;">
    							{$post['message']}
    						</div>
    						{$post['attachments']}
    						<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>
    			<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']}</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>
    		<td rowspan="3" class="trow1" style="white-space: nowrap; width: 10%; vertical-align: top; text-align: center;"> 
    			<div style="overflow: hidden; width: 100%;"> 
    				<strong>Download: <a href="{$GLOBALS['threadfields']['mhdld_file']['url']}">{$GLOBALS['threadfields']['mhdld_file']['filename']}</a></strong><br />
    				<span class="smalltext">
    					Downloads: {$GLOBALS['threadfields']['mhdld_file']['downloads_friendly']}<br />
    					Last Updated: {$GLOBALS['threadfields']['mhdld_file']['update_date']}, {$GLOBALS['threadfields']['mhdld_file']['update_time']}<br /> 
    					Uploader: {$post['profilelink']}
    				</span>
    			</div>
    		</td>
    	</tr>
    </table>

  4. mhdld_postbit_inlinecheck

    HTML Code
    <input type="checkbox" class="checkbox" name="inlinemod_{$post['pid']}" id="inlinemod_{$post['pid']}" value="1" style="vertical-align: middle;" {$inlinecheck}  />

  5. mhdld_postbit_posturl

    HTML Code
    <div style="float: right; width: auto; vertical-align: top">{$post['inlinecheck']}</div>


I think that's the basic.
Reference URL's