MyBB Community Forums

Full Version: Style your attachments
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Just a simple tutorial from me. On how to style your attachments the way you want them. Example below.

Firstly go to ACP > Template & Styles > Templates > THEME > Postbit Templates > Postbit_attachments_attachment and replace the whole template with your chosen style

My personal favorite style is this
<button class="downloadlink" style="width:500px;font-family: 'lucida grande', 'lucida sans unicode', 'arial', 'verdana', 'tahoma', sans-serif' !important; onclick="window.open('/attachment.php?aid={$attachment['aid']}');"><img style="height:35px;float:left;" src="/images/download.png" /> Download <strong>{$attachment['filename']}</strong><br />{$attachment['downloads']} Downloads &mdash; FileSize: {$attachment['filesize']}</button>

add this CSS to the bottom of your global.css for your theme.
button.downloadlink {
	border:1px solid #0c0f12;
	background:#161c21;
	background-repeat:repeat-x;
	font-family: 'VisitorTT1BRKRegular';
        padding:4px 6px;
	color:#ffffff;
        cursor:pointer;
        width:100px;
}
button.downloadlink:hover,
button.active {
	background:#11161a;
	background-repeat:repeat-x;
	border:1px solid #0c0f12;
	color:#ffffff;
}

Preview
[Image: 9t1et.png]


Style 2 (no css)
<table border="0" cellpadding="0" cellspacing="3">
<!-----Postbit_Attachment---->
	</table>
	<table class="attachtable" id="table2" width="95%" align="center" border="1" cellpadding="2" cellspacing="0">
		<tr>
			<td colspan="3" class="attachheader" width="100%" align="center"><b>
			{$attachment['filename']}</b></td>
		</tr>
		<tr>
			<td class="attachrow" width="15%"><span class="genmed">File Type:</span></td>
			<td class="attachrow" width="75%">
			{$attachment['icon']}</td>
			<td rowspan="3" class="attachrow" width="10%" align="center">
			<a href="attachment.php?aid={$attachment['aid']}">
			<img src="images/download.png" alt="" border="0"></a><br>
</td>		</tr>
		<tr>
			<td class="attachrow" width="15%"><span class="genmed">Downloaded:</span></td>
			<td class="attachrow" width="75%"><span class="genmed">{$attachment['downloads']} times</span></td>
		</tr>
		<tr>
			<td class="attachrow" width="15%"><span class="genmed">Size:</span></td>
			<td class="attachrow" width="75%">{$attachment['filesize']}</td>
		</tr>
	</table>

Preview
[Image: N4XR9.png]

Download image
[Image: 92Wpr.png]

FIXED THE LINK NOT WORKING!
Very nice, was looking for this!
(2012-07-12, 09:38 AM)xvidmaster97x Wrote: [ -> ]Very nice, was looking for this!

thanks Smile

Fixed a small bug where the image wouldn't show Smile
I tried the 1st style, with the additional CSS. It looks like above, but when I click on it, no attachment is downloading or coming up. Its like something you can click on but nothing happend. Did i miss something ?

Wolfseye

Anyone ?
Does anyone know why this doesn't work ? Sad
Possibly because there might be some &nbsp; characters appeared while copying and pasting the code from here.

Revert those edit template(s) back to default, disable codepress, and then re-edit the template(s) again.

In order to disable codepress, follow this:
AdminCP > Preferences > Turn on / off Codepress > and select "Off".
Don't find the backup of the template content anymore. Sad Could you please post the original template content of that template from the default theme ?

UPDATE:
Nevermind, i took the less fancy version (without the .css) and that works fine. Wink
No need for the backup, MyBB already cache/store the template's default code.

AdminCP > Templates > Your theme's templates > Postbit Templates > and left click [Options] button infront of "Postbit_attachments_attachment" template and select "Revert it to original". Smile
inorder for this to work in the newest mybb i found out it won't work in the template the author has stated.

<button class="downloadlink" style="width:500px;font-family: 'lucida grande', 'lucida sans unicode', 'arial', 'verdana', 'tahoma', sans-serif' !important;" onclick="window.open('/attachment.php?aid={$attachment['aid']}');"><img style="height:35px;float:left;" src="http://i.imgur.com/92Wpr.png" /> Download <strong>{$attachment['filename']}</strong><br />{$attachment['downloads']} Downloads &mdash; FileSize: {$attachment['filesize']}</button> 

this one will work for the newest and also has the code fixed.

i had to use: postbit_attachments to get it to work
(2014-02-05, 09:01 AM)leroymcqy Wrote: [ -> ]inorder for this to work in the newest mybb i found out it won't work in the template the author has stated.

<button class="downloadlink" style="width:500px;font-family: 'lucida grande', 'lucida sans unicode', 'arial', 'verdana', 'tahoma', sans-serif' !important;" onclick="window.open('/attachment.php?aid={$attachment['aid']}');"><img style="height:35px;float:left;" src="http://i.imgur.com/92Wpr.png" /> Download <strong>{$attachment['filename']}</strong><br />{$attachment['downloads']} Downloads &mdash; FileSize: {$attachment['filesize']}</button> 

this one will work for the newest and also has the code fixed.

i had to use: postbit_attachments to get it to work

for anyone using the 1.6 version of mybb, this also works on it to.
Pages: 1 2