Advertisement:

Author Topic: how to do manual limit 4  (Read 526 times)

Offline Replikacep

  • Jr. Member
  • **
  • Posts: 381
  • Gender: Male
    • Orjinal Cin Kore Telefon lari Rom ve Destek
how to do manual limit 4
« 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

Code: [Select]
/**
 * 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 -->';

Offline Bigguy

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,898
  • Gender: Male
  • Be nice, or else....
    • smfbigguy on GitHub
    • SMF Helper
Re: how to do manual limit 4
« Reply #1 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. ??

Offline Replikacep

  • Jr. Member
  • **
  • Posts: 381
  • Gender: Male
    • Orjinal Cin Kore Telefon lari Rom ve Destek
Re: how to do manual limit 4
« Reply #2 on: January 23, 2019, 07:33:42 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

Offline Replikacep

  • Jr. Member
  • **
  • Posts: 381
  • Gender: Male
    • Orjinal Cin Kore Telefon lari Rom ve Destek
Re: how to do manual limit 4
« Reply #3 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

Offline Bigguy

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,898
  • Gender: Male
  • Be nice, or else....
    • smfbigguy on GitHub
    • SMF Helper
Re: how to do manual limit 4
« Reply #4 on: January 23, 2019, 08:58:27 AM »
Ah I see. Ya better wait for someone with better coding skills than I have.  :)

Offline Replikacep

  • Jr. Member
  • **
  • Posts: 381
  • Gender: Male
    • Orjinal Cin Kore Telefon lari Rom ve Destek
Re: how to do manual limit 4
« Reply #5 on: January 24, 2019, 01:25:17 PM »
https://web-develop.ca/index.php?topic=372.0#quickreply

Quote from: Chen Zhen link=msg=2182 date=1548345415
Code: [Select]
$x = 0;
foreach ($context['latest_posts'] as $post){
$x++;
if ($x > 4)
{break;}

was Thank you
[/quote]

@Chen Zhen

was Thank you