MyBB Community Forums

Full Version: Please how can i add recent posts without plugins
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Please how can i add recent posts without plugins, please with details on how to post the code cos i am a novice in mybb. thanks in advance...
Quite simple actually, what we will be doing is adding the exact same code present in portal.php to index.php.

$latestthreads = '';
// Latest forum discussions
if($mybb->settings['portal_showdiscussions'] != 0 && $mybb->settings['portal_showdiscussionsnum'] && $mybb->settings['portal_excludediscussion'] != -1)
{
	$altbg = alt_trow();
	$threadlist = '';
	$excludeforums = '';
	if(!empty($mybb->settings['portal_excludediscussion']))
	{
		$excludeforums = "AND t.fid NOT IN ({$mybb->settings['portal_excludediscussion']})";
	}
	$query = $db->query("
		SELECT t.tid, t.fid, t.uid, t.lastpost, t.lastposteruid, t.lastposter, t.subject, t.replies, t.views, u.username
		FROM ".TABLE_PREFIX."threads t
		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
		WHERE 1=1 {$excludeforums}{$tunviewwhere} AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
		ORDER BY t.lastpost DESC
		LIMIT 0, ".$mybb->settings['portal_showdiscussionsnum']
	);
	while($thread = $db->fetch_array($query))
	{
		$forumpermissions[$thread['fid']] = forum_permissions($thread['fid']);
		// Make sure we can view this thread
		if(isset($forumpermissions[$thread['fid']]['canonlyviewownthreads']) && $forumpermissions[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid'])
		{
			continue;
		}
		$lastpostdate = my_date('relative', $thread['lastpost']);
		if(!$thread['lastposteruid'] && !$thread['lastposter'])
		{
			$lastposter = htmlspecialchars_uni($lang->guest);
		}
		else
		{
			$lastposter = htmlspecialchars_uni($thread['lastposter']);
		}
		$thread['replies'] = my_number_format($thread['replies']);
		$thread['views'] = my_number_format($thread['views']);
		// Don't link to guest's profiles (they have no profile).
		if($thread['lastposteruid'] == 0)
		{
			$lastposterlink = $lastposter;
		}
		else
		{
			$lastposterlink = build_profile_link($lastposter, $thread['lastposteruid']);
		}
		$thread['subject'] = $thread['fullsubject'] = $parser->parse_badwords($thread['subject']);
		if(my_strlen($thread['subject']) > 25)
		{
			$thread['subject'] = my_substr($thread['subject'], 0, 25) . "...";
		}
		$thread['subject'] = htmlspecialchars_uni($thread['subject']);
		$thread['fullsubject'] = htmlspecialchars_uni($thread['fullsubject']);
		$thread['threadlink'] = get_thread_link($thread['tid']);
		$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
		$thread['forumlink'] = get_forum_link($thread['fid']);
		$thread['forumname'] = $forum_cache[$thread['fid']]['name'];
		eval("\$threadlist .= \"".$templates->get("portal_latestthreads_thread")."\";");
		$altbg = alt_trow();
	}
	if($threadlist)
	{
		// Show the table only if there are threads
		eval("\$latestthreads = \"".$templates->get("portal_latestthreads")."\";");
	}
}

Replace your portal_latestthreads_thread
<tr class="latestthreads_portal">
<tr>
<td class="{$altbg}">
<strong><avatarep_uid_[{$thread['lastposteruid']}]><a href="{$mybb->settings['bburl']}/{$thread['threadlink']}">{$thread['subject']}</a></strong>
<span class="smalltext"><br />
{$lang->forum} <a href="{$thread['forumlink']}">{$thread['forumname']}</a><br />
<a href="{$thread['lastpostlink']}">{$lang->latest_threads_lastpost}</a> {$lastposterlink}<br />
{$lastpostdate}<br />
<strong>&raquo; </strong>Replies: {$thread['replies']}<br />
<strong>&raquo; </strong>Views: {$thread['views']}
</span>
</td>
</tr>


Finally add this in your index template,
{$latestthreads}

If your theme supports sidebar, than add the above code in sidebar code. Otherwise you need to create sidebar yourself Smile

Cheers
WallBB
(2018-10-04, 11:19 AM)WallBB Wrote: [ -> ]Quite simple actually, what we will be doing is adding the exact same code present in portal.php to index.php.

$latestthreads = '';
// Latest forum discussions
if($mybb->settings['portal_showdiscussions'] != 0 && $mybb->settings['portal_showdiscussionsnum'] && $mybb->settings['portal_excludediscussion'] != -1)
{
	$altbg = alt_trow();
	$threadlist = '';
	$excludeforums = '';
	if(!empty($mybb->settings['portal_excludediscussion']))
	{
		$excludeforums = "AND t.fid NOT IN ({$mybb->settings['portal_excludediscussion']})";
	}
	$query = $db->query("
		SELECT t.tid, t.fid, t.uid, t.lastpost, t.lastposteruid, t.lastposter, t.subject, t.replies, t.views, u.username
		FROM ".TABLE_PREFIX."threads t
		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
		WHERE 1=1 {$excludeforums}{$tunviewwhere} AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
		ORDER BY t.lastpost DESC
		LIMIT 0, ".$mybb->settings['portal_showdiscussionsnum']
	);
	while($thread = $db->fetch_array($query))
	{
		$forumpermissions[$thread['fid']] = forum_permissions($thread['fid']);
		// Make sure we can view this thread
		if(isset($forumpermissions[$thread['fid']]['canonlyviewownthreads']) && $forumpermissions[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid'])
		{
			continue;
		}
		$lastpostdate = my_date('relative', $thread['lastpost']);
		if(!$thread['lastposteruid'] && !$thread['lastposter'])
		{
			$lastposter = htmlspecialchars_uni($lang->guest);
		}
		else
		{
			$lastposter = htmlspecialchars_uni($thread['lastposter']);
		}
		$thread['replies'] = my_number_format($thread['replies']);
		$thread['views'] = my_number_format($thread['views']);
		// Don't link to guest's profiles (they have no profile).
		if($thread['lastposteruid'] == 0)
		{
			$lastposterlink = $lastposter;
		}
		else
		{
			$lastposterlink = build_profile_link($lastposter, $thread['lastposteruid']);
		}
		$thread['subject'] = $thread['fullsubject'] = $parser->parse_badwords($thread['subject']);
		if(my_strlen($thread['subject']) > 25)
		{
			$thread['subject'] = my_substr($thread['subject'], 0, 25) . "...";
		}
		$thread['subject'] = htmlspecialchars_uni($thread['subject']);
		$thread['fullsubject'] = htmlspecialchars_uni($thread['fullsubject']);
		$thread['threadlink'] = get_thread_link($thread['tid']);
		$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
		$thread['forumlink'] = get_forum_link($thread['fid']);
		$thread['forumname'] = $forum_cache[$thread['fid']]['name'];
		eval("\$threadlist .= \"".$templates->get("portal_latestthreads_thread")."\";");
		$altbg = alt_trow();
	}
	if($threadlist)
	{
		// Show the table only if there are threads
		eval("\$latestthreads = \"".$templates->get("portal_latestthreads")."\";");
	}
}

Replace your portal_latestthreads_thread
<tr class="latestthreads_portal">
<tr>
<td class="{$altbg}">
<strong><avatarep_uid_[{$thread['lastposteruid']}]><a href="{$mybb->settings['bburl']}/{$thread['threadlink']}">{$thread['subject']}</a></strong>
<span class="smalltext"><br />
{$lang->forum} <a href="{$thread['forumlink']}">{$thread['forumname']}</a><br />
<a href="{$thread['lastpostlink']}">{$lang->latest_threads_lastpost}</a> {$lastposterlink}<br />
{$lastpostdate}<br />
<strong>&raquo; </strong>Replies: {$thread['replies']}<br />
<strong>&raquo; </strong>Views: {$thread['views']}
</span>
</td>
</tr>


Finally add this in your index template,
{$latestthreads}

If your theme supports sidebar, than add the above code in sidebar code. Otherwise you need to create sidebar yourself Smile

Cheers
WallBB
 Hello, thanks for your response, please how do i get to index.php please i am new to mybb, please help me. thanks
Index.php is located in your file area of your server/host. Accessed either by cPanel (the panel where all of your website tools are) file manager or an FTP client of some sorts.
fyi, if you searched the forums you would find my past instructions provided to other users for latest threads on index that was provided a a downloadable instruction file for example here:  Anyhoo, this is how you actually do it


In index.php find:

$plugins->run_hooks('index_start');



Add this after:


// start threadlist on index

// get forums user cannot view
$unviewable = get_unviewable_forums(true);
if($unviewable)
{
        $unviewwhere = " AND fid NOT IN ($unviewable)";
}

        $altbg = alt_trow();
        $threadlist = '';
        $query = $db->query("
                SELECT t.*, u.username
                FROM ".TABLE_PREFIX."threads t
                LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
                WHERE 1=1 $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
                ORDER BY t.lastpost DESC
                LIMIT 0, 10"
        );
        while($thread = $db->fetch_array($query))
        {
                $lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
                $lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
                // Don't link to guest's profiles (they have no profile).
                if($thread['lastposteruid'] == 0)
                {
                        $lastposterlink = $thread['lastposter'];
                }
                else
                {
                        $lastposterlink = build_profile_link($thread['lastposter'], $thread['lastposteruid']);
                }
                if(my_strlen($thread['subject']) > 25)
                {
                        $thread['subject'] = my_substr($thread['subject'], 0, 25) . "...";
                }
                $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
                $thread['threadlink'] = get_thread_link($thread['tid']);
                $thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
                eval("\$threadlist .= \"".$templates->get("portal_latestthreads_thread")."\";");
                $altbg = alt_trow();
        }
        if($threadlist)
        {
                // Show the table only if there are threads
                eval("\$latestthreads = \"".$templates->get("portal_latestthreads")."\";");
        } 

// end threadlist on index


Or you can replace your inde.php with the attached index.php below:





Add this to: inc/languages/english/global.lang.php
$l['posted_by'] = "Posted by:";
$l['forum'] = "Forum:";
$l['replies'] = "Replies";
$l['no_replies'] = "No Replies";
$l['latest_threads'] = "Latest Threads";
$l['latest_threads_replies'] = "Replies:";
$l['latest_threads_views'] = "Views:";
$l['latest_threads_lastpost'] = "Last Post:";


Add this to: global.css

.sidebar {
    float: right;
    width: 20%
}

.forum {
    float: left;
    width: 79%
}

Replace all of Index template with:

<html>
<head>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
<script type="text/javascript">
<!--
	lang.no_new_posts = "{$lang->no_new_posts}";
	lang.click_mark_read = "{$lang->click_mark_read}";
// -->
</script>
</head>
<body>
{$header}
	
<div class="forum"> 
  {$forums} 
</div>
	
<div class="sidebar">
  {$latestthreads} 
</div>
	
{$boardstats}

<dl class="forum_legend smalltext">
	<dt><span class="forum_status forum_on" title="{$lang->new_posts}"></span></dt>
	<dd>{$lang->new_posts}</dd>

	<dt><span class="forum_status forum_off" title="{$lang->no_new_posts}"></span></dt>
	<dd>{$lang->no_new_posts}</dd>

	<dt><span class="forum_status forum_offclose" title="{$lang->forum_closed}"></span></dt>
	<dd>{$lang->forum_closeded}</dd>

	<dt><span class="forum_status forum_offlink" title="{$lang->forum_redirect}"></span></dt>
	<dd>{$lang->forum_redirect}</dd>
</dl>
<br class="clear" />
{$footer}
</body>
</html>


Now you want to make the threadlist collapsible:

Replace portal_latestthreads with:

<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    <tr>
      <td class="thead"><strong>{$lang->latest_threads}</strong>
        <div class="expcolimage"><img src="{$theme['imgdir']}/collapse.png" id="sidebar_ex1_img" class="expander" alt="[-]" title="[-]" /></div></td>
    </tr>
    <tbody style="{$collapsed['sidebar_ex1_e']}" id="sidebar_ex1_e">
     {$threadlist}
    </tbody>
  </table>
  <br />


Replace portal_latestthreads_thread with:


<tr>
<td class="{$altbg}">
<strong><a href="{$mybb->settings['bburl']}/{$thread['threadlink']}">{$thread['subject']}</a></strong>
<span class="smalltext"><br />
{$lang->forum} <a href="{$mybb->settings['bburl']}/{$thread['forumlink']}">{$thread['forumname']}</a><br />
<a href="{$mybb->settings['bburl']}/{$thread['lastpostlink']}">{$lang->latest_threads_lastpost}</a> {$lastposterlink}<br />
{$lastpostdate} {$lastposttime}<br />
<strong>&raquo; </strong>{$lang->latest_threads_replies} {$thread['replies']}<br />
<strong>&raquo; </strong>{$lang->latest_threads_views} {$thread['views']}
</span>
</td>
</tr>


replace css3.css with:


tr td.trow1:first-child,
tr td.trow2:first-child,
tr td.trow_shaded:first-child {
	border-left: 0;
}

tr td.trow1:last-child,
tr td.trow2:last-child,
tr td.trow_shaded:last-child {
	border-right: 0;
}

.tborder {
	-moz-border-radius: 7px;
	-webkit-border-radius: 7px;
	border-radius: 7px;
}

.tborder tbody tr:last-child > td {
	border-bottom: 0;
}

.tborder tbody tr:last-child > td:first-child {
}

.tborder tbody tr:last-child > td:last-child {
}

.thead {
	-moz-border-radius-topleft: 6px;
	-moz-border-radius-topright: 6px;
	-webkit-border-top-left-radius: 6px;
	-webkit-border-top-right-radius: 6px;
	border-top-left-radius: 6px;
	border-top-right-radius: 6px;
}

.thead_collapsed {
	-moz-border-radius-bottomleft: 6px;
	-moz-border-radius-bottomright: 6px;
	-webkit-border-bottom-left-radius: 6px;
	-webkit-border-bottom-right-radius: 6px;
	border-bottom-left-radius: 6px;
	border-bottom-right-radius: 6px;
}

.thead_left {
	-moz-border-radius-topright: 0;
	-webkit-border-top-right-radius: 0;
    border-top-right-radius: 0;
}

.thead_right {
	-moz-border-radius-topleft: 0;
	-webkit-border-top-left-radius: 0;
    border-top-left-radius: 0;
}

.tcat_menu {
	-moz-border-radius: 0 !important;
	-webkit-border-radius: 0 !important;
  	border-radius: 0 !important;
}

.tborder tbody:nth-last-child(2) .tcat_collapse_collapsed {
	-moz-border-radius-bottomleft: 6px !important;
	-moz-border-radius-bottomright: 6px !important;
	-webkit-border-bottom-left-radius: 6px !important;
	-webkit-border-bottom-right-radius: 6px !important;
	border-bottom-left-radius: 6px !important;
	border-bottom-right-radius: 6px !important;
}

button,
input.button,
input.textbox,
input.invalid_field,
input.valid_field,
select,
textarea,
.editor_control_bar,
blockquote,
.codeblock,
fieldset,
.pm_alert,
.red_alert,
.popup_menu,
.postbit_buttons > a,
a.button {
	-moz-border-radius: 6px;
	-webkit-border-radius: 6px;
	border-radius: 6px;
}

(2018-10-04, 07:51 PM)vintagedaddyo Wrote: [ -> ]fyi, if you searched the forums you would find my past instructions provided to other users for latest threads on index that was provided a a downloadable instruction file for example here:  Anyhoo, this is how you actually do it


In index.php find:

$plugins->run_hooks('index_start');



Add this after:


// start threadlist on index

// get forums user cannot view
$unviewable = get_unviewable_forums(true);
if($unviewable)
{
        $unviewwhere = " AND fid NOT IN ($unviewable)";
}

        $altbg = alt_trow();
        $threadlist = '';
        $query = $db->query("
                SELECT t.*, u.username
                FROM ".TABLE_PREFIX."threads t
                LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
                WHERE 1=1 $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
                ORDER BY t.lastpost DESC
                LIMIT 0, 10"
        );
        while($thread = $db->fetch_array($query))
        {
                $lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
                $lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
                // Don't link to guest's profiles (they have no profile).
                if($thread['lastposteruid'] == 0)
                {
                        $lastposterlink = $thread['lastposter'];
                }
                else
                {
                        $lastposterlink = build_profile_link($thread['lastposter'], $thread['lastposteruid']);
                }
                if(my_strlen($thread['subject']) > 25)
                {
                        $thread['subject'] = my_substr($thread['subject'], 0, 25) . "...";
                }
                $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
                $thread['threadlink'] = get_thread_link($thread['tid']);
                $thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
                eval("\$threadlist .= \"".$templates->get("portal_latestthreads_thread")."\";");
                $altbg = alt_trow();
        }
        if($threadlist)
        {
                // Show the table only if there are threads
                eval("\$latestthreads = \"".$templates->get("portal_latestthreads")."\";");
        } 

// end threadlist on index


Or you can replace your inde.php with the attached index.php below:





Add this to: inc/languages/english/global.lang.php
$l['posted_by'] = "Posted by:";
$l['forum'] = "Forum:";
$l['replies'] = "Replies";
$l['no_replies'] = "No Replies";
$l['latest_threads'] = "Latest Threads";
$l['latest_threads_replies'] = "Replies:";
$l['latest_threads_views'] = "Views:";
$l['latest_threads_lastpost'] = "Last Post:";


Add this to: global.css

.sidebar {
    float: right;
    width: 20%
}

.forum {
    float: left;
    width: 79%
}

Replace all of Index template with:

<html>
<head>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
<script type="text/javascript">
<!--
	lang.no_new_posts = "{$lang->no_new_posts}";
	lang.click_mark_read = "{$lang->click_mark_read}";
// -->
</script>
</head>
<body>
{$header}
	
<div class="forum"> 
  {$forums} 
</div>
	
<div class="sidebar">
  {$latestthreads} 
</div>
	
{$boardstats}

<dl class="forum_legend smalltext">
	<dt><span class="forum_status forum_on" title="{$lang->new_posts}"></span></dt>
	<dd>{$lang->new_posts}</dd>

	<dt><span class="forum_status forum_off" title="{$lang->no_new_posts}"></span></dt>
	<dd>{$lang->no_new_posts}</dd>

	<dt><span class="forum_status forum_offclose" title="{$lang->forum_closed}"></span></dt>
	<dd>{$lang->forum_closeded}</dd>

	<dt><span class="forum_status forum_offlink" title="{$lang->forum_redirect}"></span></dt>
	<dd>{$lang->forum_redirect}</dd>
</dl>
<br class="clear" />
{$footer}
</body>
</html>


Now you want to make the threadlist collapsible:

Replace portal_latestthreads with:

<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    <tr>
      <td class="thead"><strong>{$lang->latest_threads}</strong>
        <div class="expcolimage"><img src="{$theme['imgdir']}/collapse.png" id="sidebar_ex1_img" class="expander" alt="[-]" title="[-]" /></div></td>
    </tr>
    <tbody style="{$collapsed['sidebar_ex1_e']}" id="sidebar_ex1_e">
     {$threadlist}
    </tbody>
  </table>
  <br />


Replace portal_latestthreads_thread with:


<tr>
<td class="{$altbg}">
<strong><a href="{$mybb->settings['bburl']}/{$thread['threadlink']}">{$thread['subject']}</a></strong>
<span class="smalltext"><br />
{$lang->forum} <a href="{$mybb->settings['bburl']}/{$thread['forumlink']}">{$thread['forumname']}</a><br />
<a href="{$mybb->settings['bburl']}/{$thread['lastpostlink']}">{$lang->latest_threads_lastpost}</a> {$lastposterlink}<br />
{$lastpostdate} {$lastposttime}<br />
<strong>&raquo; </strong>{$lang->latest_threads_replies} {$thread['replies']}<br />
<strong>&raquo; </strong>{$lang->latest_threads_views} {$thread['views']}
</span>
</td>
</tr>


replace css3.css with:


tr td.trow1:first-child,
tr td.trow2:first-child,
tr td.trow_shaded:first-child {
	border-left: 0;
}

tr td.trow1:last-child,
tr td.trow2:last-child,
tr td.trow_shaded:last-child {
	border-right: 0;
}

.tborder {
	-moz-border-radius: 7px;
	-webkit-border-radius: 7px;
	border-radius: 7px;
}

.tborder tbody tr:last-child > td {
	border-bottom: 0;
}

.tborder tbody tr:last-child > td:first-child {
}

.tborder tbody tr:last-child > td:last-child {
}

.thead {
	-moz-border-radius-topleft: 6px;
	-moz-border-radius-topright: 6px;
	-webkit-border-top-left-radius: 6px;
	-webkit-border-top-right-radius: 6px;
	border-top-left-radius: 6px;
	border-top-right-radius: 6px;
}

.thead_collapsed {
	-moz-border-radius-bottomleft: 6px;
	-moz-border-radius-bottomright: 6px;
	-webkit-border-bottom-left-radius: 6px;
	-webkit-border-bottom-right-radius: 6px;
	border-bottom-left-radius: 6px;
	border-bottom-right-radius: 6px;
}

.thead_left {
	-moz-border-radius-topright: 0;
	-webkit-border-top-right-radius: 0;
    border-top-right-radius: 0;
}

.thead_right {
	-moz-border-radius-topleft: 0;
	-webkit-border-top-left-radius: 0;
    border-top-left-radius: 0;
}

.tcat_menu {
	-moz-border-radius: 0 !important;
	-webkit-border-radius: 0 !important;
  	border-radius: 0 !important;
}

.tborder tbody:nth-last-child(2) .tcat_collapse_collapsed {
	-moz-border-radius-bottomleft: 6px !important;
	-moz-border-radius-bottomright: 6px !important;
	-webkit-border-bottom-left-radius: 6px !important;
	-webkit-border-bottom-right-radius: 6px !important;
	border-bottom-left-radius: 6px !important;
	border-bottom-right-radius: 6px !important;
}

button,
input.button,
input.textbox,
input.invalid_field,
input.valid_field,
select,
textarea,
.editor_control_bar,
blockquote,
.codeblock,
fieldset,
.pm_alert,
.red_alert,
.popup_menu,
.postbit_buttons > a,
a.button {
	-moz-border-radius: 6px;
	-webkit-border-radius: 6px;
	border-radius: 6px;
}

thanks...
Get it by jquery from portal page
please how can i increase and decrease the number of recent posts in my homepage after forum without plugin
(2018-10-07, 03:31 AM)Christineg5 Wrote: [ -> ]please how can i increase and decrease the number of recent posts in my homepage after forum without plugin


In ACP visit: Home » Board Settings » Portal Settings

"Number of latest discussions to show"

change from "10" to your desired #

Update: Oops, if you followed my instructions I forgot I have it hard-coded to 10..., but I can quickly correct that.., my bad.

In index find the code we added and find in that:


        $query = $db->query("
                SELECT t.*, u.username
                FROM ".TABLE_PREFIX."threads t
                LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
                WHERE 1=1 $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
                ORDER BY t.lastpost DESC
                LIMIT 0, 10"
        );


And change it to:


        $query = $db->query("
                SELECT t.*, u.username
                FROM ".TABLE_PREFIX."threads t
                LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
                WHERE 1=1 $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
                ORDER BY t.lastpost DESC
                LIMIT 0, ".$mybb->settings['portal_showdiscussionsnum']
        );


Now when you change the discussion amount in portal settings it with be reflected in index as well. if you don't want to make the edit..., the changed index.php file can be found below for you to upload and overwrite with the previous.

[attachment=40993]
(2018-10-07, 04:07 AM)vintagedaddyo Wrote: [ -> ]
(2018-10-07, 03:31 AM)Christineg5 Wrote: [ -> ]please how can i increase and decrease the number of recent posts in my homepage after forum without plugin


In ACP visit: Home » Board Settings » Portal Settings

"Number of latest discussions to show"

change from "10" to your desired #

Update: Oops, if you followed my instructions I forgot I have it hard-coded to 10..., but I can quickly correct that.., my bad.

In index find the code we added and find in that:


        $query = $db->query("
                SELECT t.*, u.username
                FROM ".TABLE_PREFIX."threads t
                LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
                WHERE 1=1 $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
                ORDER BY t.lastpost DESC
                LIMIT 0, 10"
        );


And change it to:


        $query = $db->query("
                SELECT t.*, u.username
                FROM ".TABLE_PREFIX."threads t
                LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
                WHERE 1=1 $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
                ORDER BY t.lastpost DESC
                LIMIT 0, ".$mybb->settings['portal_showdiscussionsnum']
        );


Now when you change the discussion amount in portal settings it with be reflected in index as well. if you don't want to make the edit..., the changed index.php file can be found below for you to upload and overwrite with the previous.

Thank you very much