Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Aiheen aloitti: AlenNS - heinäkuu 03, 2008, 01:30:06 IP

Otsikko: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: AlenNS - heinäkuu 03, 2008, 01:30:06 IP
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.
Otsikko: Re: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: searchgr - heinäkuu 04, 2008, 11:07:20 AP
I think that you have to use the 'Insert Table'
Otsikko: Re: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: AlenNS - heinäkuu 04, 2008, 11:41:09 AP
Lainaus käyttäjältä: searchgr - heinäkuu 04, 2008, 11:07:20 AP
I think that you have to use the 'Insert Table'
I don't understand... :(
Otsikko: Re: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: searchgr - heinäkuu 04, 2008, 11:46:29 AP
Post menu
Use the
Otsikko: Re: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: AlenNS - heinäkuu 04, 2008, 11:58:25 AP
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.
Otsikko: Re: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: metallica48423 - heinäkuu 05, 2008, 04:26:04 AP
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
Otsikko: Re: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: AlenNS - heinäkuu 05, 2008, 07:48:02 AP
Lainaus käyttäjältä: metallica48423 - heinäkuu 05, 2008, 04:26:04 AP
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! :)
Otsikko: Re: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: metallica48423 - heinäkuu 05, 2008, 08:04:28 AP
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
Otsikko: Re: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: AlenNS - heinäkuu 05, 2008, 09:16:10 AP
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.
(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>';
(http://www.turboimagehost.com/p/486508/2.JPG.html)

On this picture I removed all the <br /> codes.
(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.

(http://www.turboimagehost.com/p/486510/4.JPG.html)

Otsikko: Re: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: metallica48423 - heinäkuu 05, 2008, 10:04:51 AP
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
Otsikko: Re: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: AlenNS - heinäkuu 05, 2008, 10:16:01 AP
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!
Otsikko: Re: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: metallica48423 - heinäkuu 05, 2008, 10:19:31 AP
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.
Otsikko: Re: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: AlenNS - heinäkuu 05, 2008, 10:24:54 AP
Yes, but now the text size is bigger then earlier.

(http://www.turboimagehost.com/p/486636/1.JPG.html)
Otsikko: Re: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: metallica48423 - heinäkuu 05, 2008, 10:41:50 AP
you could do something like

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

instead of

<td width="50%" style="padding: 5px;">
Otsikko: Re: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: AlenNS - heinäkuu 05, 2008, 10:49:07 AP
That's it.
Thanks a lot. That solved my problem. :)
Otsikko: Re: Attachment in SMF 2.0 Beta 3.1
Kirjoitti: Xavi-Nena - maaliskuu 16, 2009, 09:57:20 IP
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