SimplePortal
Customization => Custom Coding => Topic started by: Ginarr on August 28, 2009, 10:28:32 PM
-
SMF version: 1.1.10
SimplePortal version: 2.2.2
Errors: None.
I'm having an issue with the default "Recent Image Attachments" block. It seems to stretch off to the right side of the page. I have it set to show 12 images, horizontally. However, the effect I was going for was 3 rows, 4 images per row. I'm not sure how to achieve this within SP. How can I keep the default look of the block, and have them in rows that fit to any block size? I have attached an example of what is occurring.
Thanks for any help!
-
Any ideas anyone?
-
Moved to the Custom Coding board.
Replace this code:
echo '
<table class="sp_auto_align">', $direction ? '
<tr>' : '';
foreach ($items as $item)
{
echo !$direction ? '
<tr>' : '', '
<td>
<div class="sp_image smalltext">
<a href="', $item['file']['href'], '">', $item['file']['filename'], '</a><br />
', $item['file']['image']['link'], '<br />
', $txt['sp-downloadsCount'], ': ', $item['file']['downloads'], '<br />
', $txt['sp-downloadsPoster'], ': ', $item['member']['link'], '
</div>
</td>', !$direction ? '
</tr>' : '';
}
echo $direction ? '
</tr>' : '', '
</table>';
With this code:
echo '
<table class="sp_auto_align">';
$num_per_row = 4;
$i = 1;
foreach ($items as $item)
{
echo (fmod($i, $num_per_row) == 1) ? '
<tr>': '', '
<td>
<div class="sp_image smalltext">
<a href="', $item['file']['href'], '">', $item['file']['filename'], '</a><br />
', $item['file']['image']['link'], '<br />
', $txt['sp-downloadsCount'], ': ', $item['file']['downloads'], '<br />
', $txt['sp-downloadsPoster'], ': ', $item['member']['link'], '
</div>
</td>', (fmod($i, $num_per_row) == ($num_per_row - 1)) ? '
</tr>' : '';
$i++;
}
echo '
</table>';
You can change the number per row, using the variable there.
-
Thank you!
I had to tweak the code a bit. It seems the alignment wanted to be centered. So, the 4th image always went down the the second row...
I kept:
', $direction ? '
In the code, in-replace of:
', (fmod($i, $num_per_row) == ($num_per_row - 1)) ? '
And it does what I want, unless this is the incorrect way? It does work how I imagined though.
This is what I have now:
echo '
<table class="sp_auto_align">', $direction ? '
<tr>' : '';
$num_per_row = 4;
$i = 1;
foreach ($items as $item)
{
echo (fmod($i, $num_per_row) == 1) ? '
<tr>' : '', '
<td>
<div class="sp_image smalltext">
', $item['file']['image']['link'], '<br />
Views: ', $item['file']['downloads'], '<br />
', $txt['sp-downloadsPoster'], ': ', $item['member']['link'], '
</div>
</td>', !$direction ? '
</tr>' : '';
$i++;
}
echo $direction ? '
</tr>' : '', '
</table>';