Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: AlenNS on July 03, 2008, 01:30:06 PM

Title: Attachment in SMF 2.0 Beta 3.1
Post by: AlenNS on July 03, 2008, 01:30:06 PM
Can someone tell me how can I set attachments to be placed like on picture No.2?
On picture No1 are how they are shown right now.
Thanks.
Title: Re: Attachment in SMF 2.0 Beta 3.1
Post by: searchgr on July 04, 2008, 11:07:20 AM
I think that you have to use the 'Insert Table'
Title: Re: Attachment in SMF 2.0 Beta 3.1
Post by: AlenNS on July 04, 2008, 11:41:09 AM
Quote from: searchgr on July 04, 2008, 11:07:20 AM
I think that you have to use the 'Insert Table'
I don't understand... :(
Title: Re: Attachment in SMF 2.0 Beta 3.1
Post by: searchgr on July 04, 2008, 11:46:29 AM
Post menu
Use the (https://www.simplemachines.org/community/Themes/smsite/images/bbc/table.gif)
Title: Re: Attachment in SMF 2.0 Beta 3.1
Post by: AlenNS on July 04, 2008, 11:58:25 AM
You probably didn't understand.
It is attachment not an ordinary posted picture.

My question is how to change that setting for attachment to be horisontaly placed.
Title: Re: Attachment in SMF 2.0 Beta 3.1
Post by: metallica48423 on July 05, 2008, 04:26:04 AM
in Display.template.php, the code to show attachments starts with this:

foreach ($message['attachment'] as $attachment)

To remove the line break, remove instances of <br /> inside that foreach statement
Title: Re: Attachment in SMF 2.0 Beta 3.1
Post by: AlenNS on July 05, 2008, 07:48:02 AM
Quote from: metallica48423 on July 05, 2008, 04:26:04 AM
in Display.template.php, the code to show attachments starts with this:

foreach ($message['attachment'] as $attachment)

To remove the line break, remove instances of <br /> inside that foreach statement
Thanks mate! This was helpfull! :)
Title: Re: Attachment in SMF 2.0 Beta 3.1
Post by: metallica48423 on July 05, 2008, 08:04:28 AM
did that work out alright for you?  I can pull the code itself if need be.  I think theres 3 <br />'s in there -- you might try only removing the one for image attachments though
Title: Re: Attachment in SMF 2.0 Beta 3.1
Post by: AlenNS on July 05, 2008, 09:16:10 AM
I have a problem.
I've been removing <br /> one by one, also and all of them and there were different results, but none of desired.

On picture No.1 is default setting.
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fs2d2.turboimagehost.com%2Ft%2F486507_1.JPG&hash=3a7b47ee26fbcd7f7b4fde18cab3970db11ab1b9) (http://www.turboimagehost.com/p/486507/1.JPG.html)

On this picture I removed <br /> in this section.
<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" border="0" /></a>';
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fs2d2.turboimagehost.com%2Ft%2F486508_2.JPG&hash=b7b2b43905927369efe0de3077989bd6bf6349d1) (http://www.turboimagehost.com/p/486508/2.JPG.html)

On this picture I removed all the <br /> codes.
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fs2d2.turboimagehost.com%2Ft%2F486509_3.JPG&hash=50db3959fcfcff1fc7bae9eee00023ebad0928a8) (http://www.turboimagehost.com/p/486509/3.JPG.html)

And ond this picture is how I would like to set my attachment with the description below the picture.

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fs2d2.turboimagehost.com%2Ft%2F486510_4.JPG&hash=537e8a3878fd2898272b3eaff0151eee5be24219) (http://www.turboimagehost.com/p/486510/4.JPG.html)

Title: Re: Attachment in SMF 2.0 Beta 3.1
Post by: metallica48423 on July 05, 2008, 10:04:51 AM
This is sort of a crude way to do this... hopefully it'll work for what you need though.

in Display.template.php, find:

// Now for the attachments, signature, ip logged, etc...
echo '
<tr id="msg_', $message['id'], '_footer">
<td valign="bottom" class="smalltext" width="85%">
<table width="100%" border="0" style="table-layout: fixed;"><tr>
<td colspan="2" class="smalltext" width="100%">';

// Assuming there are attachments...
if (!empty($message['attachment']))
{
echo '
<hr width="100%" size="1" class="hrcolor" />
<div style="overflow: auto; width: 100%;">';
$last_approved_state = 1;
foreach ($message['attachment'] as $attachment)
{
// Show a special box for unapproved attachments...
if ($attachment['is_approved'] != $last_approved_state)
{
$last_approved_state = 0;
echo '
<fieldset>
<legend>', $txt['attach_awaiting_approve'], '&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';sesc=', $context['session_id'], '">', $txt['approve_all'], '</a>]</legend>';
}

if ($attachment['is_image'])
{
if ($attachment['thumbnail']['has_thumb'])
echo '
<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" border="0" /></a><br />';
else
echo '
<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" border="0" /><br />';
}
echo '
<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" border="0" />&nbsp;' . $attachment['name'] . '</a> ';

if (!$attachment['is_approved'])
echo '
[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';sesc=', $context['session_id'], '">', $txt['approve'], '</a>]&nbsp;|&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';sesc=', $context['session_id'], '">', $txt['delete'], '</a>] ';
echo '
(', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . ' - ' . $txt['attach_viewed'] : ' - ' . $txt['attach_downloaded']) . ' ' . $attachment['downloads'] . ' ' . $txt['attach_times'] . '.)<br />';
}

// If we had unapproved attachments clean up.
if ($last_approved_state == 0)
echo '
</fieldset>';

echo '
</div>';
}

echo '


Replace it with:

// Now for the attachments, signature, ip logged, etc...
echo '
<tr id="msg_', $message['id'], '_footer">
<td valign="bottom" class="smalltext" width="85%">
<table width="100%" border="0" style="table-layout: fixed;"><tr>
<td colspan="2" class="smalltext" width="100%">';

echo '<table>';

$newRow = 1;

foreach ($message['attachment'] as $attachment)
{
if ($attachment['is_image'])
{
if ($attachment['thumbnail']['has_thumb'])
{

if ($newRow == 1)
{
echo '
<tr>';
}

echo '<td width="50%" style="padding: 5px;">
<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" border="0" /></a><br />';

echo '
<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" border="0" />&nbsp;' . $attachment['name'] . '</a> (', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . ' - ' . $txt['attach_viewed'] : ' - ' . $txt['attach_downloaded']) . ' ' . $attachment['downloads'] . ' ' . $txt['attach_times'] . '.)</td>';
}

else
{
echo '<td>
<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" border="0" /><br />';
echo '
<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" border="0" />&nbsp;' . $attachment['name'] . '</a> (', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . ' - ' . $txt['attach_viewed'] : ' - ' . $txt['attach_downloaded']) . ' ' . $attachment['downloads'] . ' ' . $txt['attach_times'] . '.)<br /></td>';
}

$newRow++;

if ($newRow == 3)
{
echo '</tr>';
$newRow = 1;
}

}
if(!$attachment['is_image'])
{
echo '
<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" border="0" />&nbsp;' . $attachment['name'] . '</a> (', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . ' - ' . $txt['attach_viewed'] : ' - ' . $txt['attach_downloaded']) . ' ' . $attachment['downloads'] . ' ' . $txt['attach_times'] . '.)<br />';
}
}

echo '</tr></table>


Pay particular attention to where the replace starts and stops -- otherwise you'll get a parse error :P
Title: Re: Attachment in SMF 2.0 Beta 3.1
Post by: AlenNS on July 05, 2008, 10:16:01 AM
Yeah,  great!
That's it.

Thanks a lot!

Should I control text size trough the style.css or directly on the Display.template.php

Once again thanks a lot!
Title: Re: Attachment in SMF 2.0 Beta 3.1
Post by: metallica48423 on July 05, 2008, 10:19:31 AM
I didn't change anything as far as the text size goes -- it will wrap once it reaches the halfway point between the images (they're each in their own table cell -- they can't run together (hopefully) -- so either way should work.
Title: Re: Attachment in SMF 2.0 Beta 3.1
Post by: AlenNS on July 05, 2008, 10:24:54 AM
Yes, but now the text size is bigger then earlier.

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fs2d2.turboimagehost.com%2Ft%2F486636_1.JPG&hash=149ad3be181fd762b70893cb35ff70a6c15c0be8) (http://www.turboimagehost.com/p/486636/1.JPG.html)
Title: Re: Attachment in SMF 2.0 Beta 3.1
Post by: metallica48423 on July 05, 2008, 10:41:50 AM
you could do something like

<td class="smalltext" width="50%" style="padding: 5px;">

instead of

<td width="50%" style="padding: 5px;">
Title: Re: Attachment in SMF 2.0 Beta 3.1
Post by: AlenNS on July 05, 2008, 10:49:07 AM
That's it.
Thanks a lot. That solved my problem. :)
Title: Re: Attachment in SMF 2.0 Beta 3.1
Post by: Xavi-Nena on March 16, 2009, 09:57:20 PM
Here is my display.template ...i tried the edits changes to no avail. note this code is w/out the suggested changes because it did not work when I applied it. any help is much apprecaited.

edited: i am using version 1.1.8