Hi, sorry for the delay in replying
![Smile :)](./images/smilies/icon_smile.gif)
I appreciate your patience.
I take it all of the topics are in the same forum? Say the "news" forum. And the most recent topic is to be the featured topic and the four topics thereafter are to just be shown regularly.
I think the best way to do it would be to just use an IF/ELSE inside the templating code, so something like this:
Code: Select all
$posts_ary = array(
'SELECT' => 'p.*, t.*, u.username, u.user_colour',
'FROM' => array(
POSTS_TABLE => 'p',
),
'LEFT_JOIN' => array(
array(
'FROM' => array(USERS_TABLE => 'u'),
'ON' => 'u.user_id = p.poster_id'
),
array(
'FROM' => array(TOPICS_TABLE => 't'),
'ON' => 'p.topic_id = t.topic_id'
),
),
'WHERE' => $db->sql_in_set('t.forum_id', array_keys($auth->acl_getf('f_read', true))) . '
AND t.topic_status <> ' . ITEM_MOVED . '
AND t.topic_approved = 1',
'ORDER_BY' => 'p.post_id DESC',
);
$posts = $db->sql_build_query('SELECT', $posts_ary);
$posts_result = $db->sql_query_limit($posts, $search_limit);
while( $posts_row = $db->sql_fetchrow($posts_result) )
{
$is_featured = false;
if( $i == 0 )
{
$is_featured = true;
$i++;
}
$topic_title = $posts_row['topic_title'];
$post_author = get_username_string('full', $posts_row['poster_id'], $posts_row['username'], $posts_row['user_colour']);
$post_date = $user->format_date($posts_row['post_time']);
$post_link = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=" . $posts_row['post_id'] . "#p" . $posts_row['post_id']);
$post_text = nl2br($posts_row['post_text']);
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
$bbcode->bbcode_second_pass($post_text, $posts_row['bbcode_uid'], $posts_row['bbcode_bitfield']);
$post_text = smiley_text($post_text);
$template->assign_block_vars('announcements', array(
'IS_FEATURED' => $is_featured,
'TOPIC_TITLE' => censor_text($topic_title),
'POST_AUTHOR' => $post_author,
'POST_DATE' => $post_date,
'POST_LINK' => $post_link,
'POST_TEXT' => censor_text($post_text),
));
}
What I've done there is just added a counter to make sure only the first topic is classed as featured, and can be checked using the {announcements.IS_FEATURED} template variable.
So in the template code you would have something like:
Code: Select all
<!-- BEGIN announcements -->
<!-- IF announcements.IS_FEATURED -->
Featured_Title: {announcements.TOPIC_TITLE}<br />
Featured_Post author: {announcements.POST_AUTHOR}<br />
Featured_Post date: {announcements.POST_DATE}<br />
Featured_Last post text: {announcements.POST_TEXT}<br />
Featured_Post link: {announcements.POST_LINK}
<!-- ELSE -->
Title: {announcements.TOPIC_TITLE}<br />
Post author: {announcements.POST_AUTHOR}<br />
Post date: {announcements.POST_DATE}<br />
Last post text: {announcements.POST_TEXT}<br />
Post link: {announcements.POST_LINK}
<!-- ENDIF -->
<!-- END announcements -->
Inside the if/else statements you can put the styling you want for the respective topics.
Sorry again for the delay in replying, if you have any more questions please let me know
![Smile :)](./images/smilies/icon_smile.gif)