Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Seyit replikacep.com on January 23, 2019, 07:27:38 AM

Title: how to do manual limit 4
Post by: Seyit replikacep.com on January 23, 2019, 07:27:38 AM
smf 2.1

Number of recent posts to display on board index  :  how to do manual limit 4

I need to add a fixed limit of 4

need to work independently from the theme panel

/**
* This actually displays the board index
*/
function template_main()
{
global $context, $txt, $scripturl, $memberContext;
echo '<div class="row text-center">';
/* Each post in latest_posts has:
board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
subject, short_subject (shortened with...), time, link, and href. */
foreach ($context['latest_posts'] as $post){
$last_poster = $post['poster']['id'];
if($last_poster!=0) {
// Get The Avatar the easy Way
loadMemberData($last_poster);
loadMemberContext($last_poster);

$ava = !empty($memberContext[$last_poster]['avatar']['image']) ? $memberContext[$last_poster]['avatar']['href'] : $settings['theme_url'].'/images/default_avatar.png';
} else {
$ava = $settings['theme_url'].'/images/default_avatar.png';
}
echo'
<div class="col-xl-3 col-md-6 col-12">
<div class="info-box">
<div class="blog-meta">
<span class="day">',timeformat($post['timestamp'], '%d'), '</span>
<span class="month">',timeformat($post['timestamp'], '%b'), '</span>
     </div>
<div class="title">
<header class="entry-header">
   <h6 class="inverse-font">', $post['link'], '</h6>
<div class="entry-meta">
<span class="jp-views"><img class="avatar" src="', $ava, '" />&nbsp;-&nbsp;By&nbsp;', $post['poster']['link'], '</span>
</div>
</header>
</div>
<div class="content-post">
   <p>', $post['board']['link'], '</p>
</div>
</div>
</div>';
}
echo'
</div><!-- #recent_posts_content -->';
Title: Re: how to do manual limit 4
Post by: Bigguy on January 23, 2019, 07:30:22 AM
There should be an option in the admin panel for this. Have you not found it yet. ??
Title: Re: how to do manual limit 4
Post by: Seyit replikacep.com on January 23, 2019, 07:33:42 AM
Quote from: Bigguy on January 23, 2019, 07:30:22 AM
There should be an option in the admin panel for this. Have you not found it yet. ??


Option fixed 4 on the home page do not want to limit

demo : http://demo.replikacepsatis.com/index.php
Title: Re: how to do manual limit 4
Post by: Seyit replikacep.com on January 23, 2019, 07:38:00 AM
Option fixed 4 on the home page do not want to limit

edit  : I want to do this from the code.

see picture e : http://demo.replikacepsatis.com/index.php


see the following picture
Title: Re: how to do manual limit 4
Post by: Bigguy on January 23, 2019, 08:58:27 AM
Ah I see. Ya better wait for someone with better coding skills than I have.  :)
Title: Re: how to do manual limit 4
Post by: Seyit replikacep.com on January 24, 2019, 01:25:17 PM
https://web-develop.ca/index.php?topic=372.0#quickreply

Quote from: Chen Zhen on January 24, 2019, 10:56:55 AM

$x = 0;
foreach ($context['latest_posts'] as $post){
$x++;
if ($x > 4)
{break;}


was Thank you
[/quote]

@Chen Zhen

was Thank you