• Welcome to Simple Machines Community Forum. Please login or sign up.
September 16, 2021, 06:42:01 PM

News:

Want to get involved in developing SMF, then why not lend a hand on our github!


Attachment in SMF 2.0 Beta 3.1

Started by AlenNS, July 03, 2008, 01:30:06 PM

Previous topic - Next topic

AlenNS

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.

searchgr

I think that you have to use the 'Insert Table'

AlenNS

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... :(

searchgr


AlenNS

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.

metallica48423

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
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you   
Search
Settings Repair Tool
     

AlenNS

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! :)

metallica48423

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
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you   
Search
Settings Repair Tool
     

AlenNS

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.


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>';


On this picture I removed all the <br /> codes.


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




metallica48423

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
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you   
Search
Settings Repair Tool
     

AlenNS

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!

metallica48423

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.
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you   
Search
Settings Repair Tool
     

AlenNS

Yes, but now the text size is bigger then earlier.


metallica48423

you could do something like

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

instead of

<td width="50%" style="padding: 5px;">
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you   
Search
Settings Repair Tool
     

AlenNS

That's it.
Thanks a lot. That solved my problem. :)

Xavi-Nena

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


Advertisement: