SimplePortal

Customization => Custom Coding => Topic started by: ZombieBobie on April 28, 2013, 06:38:00 PM

Title: Making news-blocks appear in rows/columns
Post by: ZombieBobie on April 28, 2013, 06:38:00 PM
Hello!

I'm trying to find a way to make board news (basically parsing a forum news board) into a format like this:

Newspost1  |  Newspost2  |  Newspost 3
Newspost4  |  Newspost5  |  Newspost 6

I've tried with the block in blocks  ( http://simpleportal.net/index.php?topic=5332.20 ), but I haven't been able to get the posts separated the way I want them to be separated.

I'm attempting to make something similar to the layout here: http://themittani.com/

Any help would be appreciated.
Title: Re: Making news-blocks appear in rows/columns
Post by: Ares on April 29, 2013, 01:19:39 AM
this code is my code to how my shoutbox and unread posts in 1 block you can modify it to do what u want

Code: [Select]
echo '<TABLE width=50% align= right>
<TR bgcolor="transparent"><TH align= left><h4 class="catbg">Shoutbox</h4></TH></TR>
<TR bgcolor="#111111"> <TD>';
$params['shoutbox'] = 2; // Your shoutbox ID
sp_shoutbox($params, 0);
echo '</TD></TABLE>';

echo '<TABLE width=50%  align= right>
<TR bgcolor="transparent"> <TH align= left><h4 class="catbg">Unread Posts</h4></TH></TR>
<TR bgcolor="#111111"> <TD>';
global $sourcedir;
@require_once($sourcedir . '/PortalUnread.php');

/* Basic settings */
$parameters['type'] = 'Posts';  /* Posts/Topics */
$parameters['limit'] = 200;  /* (int) Maximum amount of posts/topics to display */
$parameters['rows'] = '10'; /* (int) Amount of posts/topics per page */
$parameters['display'] = 'full';  /* full/compact */

/* Language Text */
$parameters['prev'] = 'Prev'; 
$parameters['next'] = 'Next';
$id = false;

sportal_unread($parameters, $id, $return_parameters = false);
echo '</TD></TABLE>';

attached preview
Title: Re: Making news-blocks appear in rows/columns
Post by: ZombieBobie on May 04, 2013, 07:33:12 AM
I'm able to format it into columns, but I haven't found a way to extract the posts so that it goes:
Post 1 | Post 2 | Post 3
Post 4 | Post 5 | Post 6


Thanks though Ares, I got two ways of making columns now :)

Title: Re: Making news-blocks appear in rows/columns
Post by: ZombieBobie on May 06, 2013, 05:42:57 PM
Well, it took a lot of fiddling.

But I got it to a decent level at least:
http://www.moxguild.com/


Thanks a lot to the people at: http://simpleportal.net/index.php?topic=5248.0;nowap


Now to convert it into dynamic resizing for tablets etc. I guess the table could be replaced ...
Title: Re: Making news-blocks appear in rows/columns
Post by: Chen Zhen on July 10, 2013, 02:35:48 PM
ZombieBobie,

  Dynamic means using javascript to alter the html after the page loads. There is no need for that as you can just use a table with 3 per row and use css for the cell widths.

ie.
Code: [Select]
$count = 0;

echo ' 
<table style="width:100%">
<tr>';
foreach ($posts as $post)
{
$count++;
echo '
<td style="width:33%">
', $post, '
</td>';
if ($count == 3)
{
$count = 0;
echo '
</tr>
<tr>';
}
}
for ($i=$count; $i>0 && $i<=3; $i++)
echo '
<td style="width=33%;">
&nbsp;
</td>';
echo '
</tr>
</table>';

If you can not guarantee at least 1 post then perhaps this would be wiser:
Code: [Select]
$count = 0;

if (!empty($posts))
{
echo ' 
<table style="width:100%">
<tr>';
foreach ($posts as $post)
{
$count++;
echo '
<td style="width:33%">
', $post, '
</td>';
if ($count == 3)
{
$count = 0;
echo '
</tr>
<tr>';
}
}
for ($i=$count; $i>0 && $i<=3; $i++)
echo '
<td style="width=33%;">
&nbsp;
</td>';
echo '
</tr>
</table>';
}
else
echo '
<span style="text-align:center;">
There are no new posts to view.
</span>';
Title: Re: Making news-blocks appear in rows/columns
Post by: newthing on July 27, 2013, 09:58:22 AM
hey Underdog.. even i was looking for somthing like this.. can you suggest me how can i have row and column in recent attachment block?????
SimplePortal 2.3.8 © 2008-2024, SimplePortal