Skip to main content
Show list of recent topics above board index Started by Jorin · · Read 13870 times 0 Members and 1 Guest are viewing this topic. previous topic - next topic - Topic derived from Re: recent posts in info center

Show list of recent topics above board index

Quote from: emanuele – Actually the package places the list at the bottom, not at the top...

Can anyone help me show the list of recent topics on top of the board index instead of the info center? Tried to make the changes as I had in SMF to show the list above the boards, but it seems I made something wrong. Didn't work.  :(

Re: Show list of recent topics above board index

Reply #1

Manual changes or using hook?

Re: Show list of recent topics above board index

Reply #2

What's better? I tried manual changes in the files.

Re: Show list of recent topics above board index

Reply #3

Both is ok to me but I can't think of a hook version for now. The manual changes should be in BoardIndex.template.php where you made this changes:

Find:
Code: [Select]
/**
 * Show information above the boardindex, like the newsfader
 */
function template_boardindex_outer_above()
{
global $context, $settings, $txt;

// Show some statistics if info centre stats is off.
if (!$settings['show_stats_index'])
echo '
<div id="index_common_stats">
', $txt['members'], ': ', $context['common_stats']['total_members'], '  •  ', $txt['posts_made'], ': ', $context['common_stats']['total_posts'], '  •  ', $txt['topics_made'], ': ', $context['common_stats']['total_topics'], '<br />
', $settings['show_latest_member'] ? ' ' . sprintf($txt['welcome_newest_member'], ' <strong>' . $context['common_stats']['latest_member']['link'] . '</strong>') : '', '
</div>';
}

Add template_ic_recent_posts() before the function closing.

Code: [Select]
/**
 * Show information above the boardindex, like the newsfader
 */
function template_boardindex_outer_above()
{
global $context, $settings, $txt;

// Show some statistics if info centre stats is off.
if (!$settings['show_stats_index'])
echo '
<div id="index_common_stats">
', $txt['members'], ': ', $context['common_stats']['total_members'], '  •  ', $txt['posts_made'], ': ', $context['common_stats']['total_posts'], '  •  ', $txt['topics_made'], ': ', $context['common_stats']['total_topics'], '<br />
', $settings['show_latest_member'] ? ' ' . sprintf($txt['welcome_newest_member'], ' <strong>' . $context['common_stats']['latest_member']['link'] . '</strong>') : '', '
</div>';
template_ic_recent_posts();
}

Re: Show list of recent topics above board index

Reply #4

The above manual changes is the basic. And since I have some extra time, I come with another suggestion.[1]


1. Like the above, open your BoardIndex.template.php and find:
Code: [Select]
/**
 * Show information above the boardindex, like the newsfader
 */
function template_boardindex_outer_above()
{
global $context, $settings, $txt;

// Show some statistics if info centre stats is off.
if (!$settings['show_stats_index'])
echo '
<div id="index_common_stats">
', $txt['members'], ': ', $context['common_stats']['total_members'], '  •  ', $txt['posts_made'], ': ', $context['common_stats']['total_posts'], '  •  ', $txt['topics_made'], ': ', $context['common_stats']['total_topics'], '<br />
', $settings['show_latest_member'] ? ' ' . sprintf($txt['welcome_newest_member'], ' <strong>' . $context['common_stats']['latest_member']['link'] . '</strong>') : '', '
</div>';
}

Add something similar to the end of it just before closing:
Code: [Select]
/**
 * Show information above the boardindex, like the newsfader
 */
function template_boardindex_outer_above()
{
global $context, $settings, $txt;

// Show some statistics if info centre stats is off.
if (!$settings['show_stats_index'])
echo '
<div id="index_common_stats">
', $txt['members'], ': ', $context['common_stats']['total_members'], '  •  ', $txt['posts_made'], ': ', $context['common_stats']['total_posts'], '  •  ', $txt['topics_made'], ': ', $context['common_stats']['total_topics'], '<br />
', $settings['show_latest_member'] ? ' ' . sprintf($txt['welcome_newest_member'], ' <strong>' . $context['common_stats']['latest_member']['link'] . '</strong>') : '', '
</div>';
template_recent_posts_2top();
}

2. We then rename function template_ic_recent_posts() to function template_ic_recent_posts2().[2]


3. Lastly, add the following at the end:
Code: [Select]
/**
 * The recent posts
 */
function template_recent_posts_2top()
{
global $context, $txt;

// Here's where the "Recent Posts" starts...
echo '
<div id="info_center" class="forum_category">
<h2 class="category_header">
<span id="category_toggle"> 
<span id="upshrink_ic2" class="', empty($context['minmax_preferences']['info']) ? 'collapse' : 'expand', '" style="display: none;" title="', $txt['hide'], '"></span>
</span>
<a href="#" id="upshrink_link2">', $txt['recent_posts'], '</a>
</h2>
<ul id="upshrinkHeaderIC2" class="category_boards"', empty($context['minmax_preferences']['info']) ? '' : ' style="display: none;"', '>';

template_ic_recent_posts2();

echo '
</ul>
</div>';

// Recent Posts collapse object.
echo '
<script><!-- // --><![CDATA[
var oInfoCenterToggle = new elk_Toggle({
bToggleEnabled: true,
bCurrentlyCollapsed: ', empty($context['minmax_preferences']['info']) ? 'false' : 'true', ',
aSwappableContainers: [
\'upshrinkHeaderIC2\'
],
aSwapClasses: [
{
sId: \'upshrink_ic2\',
classExpanded: \'collapse\',
titleExpanded: ', JavaScriptEscape($txt['hide']), ',
classCollapsed: \'expand\',
titleCollapsed: ', JavaScriptEscape($txt['show']), '
}
],
aSwapLinks: [
{
sId: \'upshrink_link2\',
msgExpanded: ', JavaScriptEscape($txt['recent_posts']), ',
msgCollapsed: ', JavaScriptEscape($txt['recent_posts']), '
}
],
oThemeOptions: {
bUseThemeSettings: ', $context['user']['is_guest'] ? 'false' : 'true', ',
sOptionName: \'minmax_preferences\',
sSessionId: elk_session_id,
sSessionVar: elk_session_var,
sAdditionalVars: \';minmax_key=info\'
},
oCookieOptions: {
bUseCookie: ', $context['user']['is_guest'] ? 'true' : 'false', ',
sCookieName: \'upshrinkIC2\'
}
});
// ]]></script>';
}

This can also be added as a hook.[3]
The following is better, I think.  ;)
The purpose is so that Info Centre won't call it and we use it only at the top.
But I won't be making it for now. :)

Re: Show list of recent topics above board index

Reply #5

Great, thanks, but:

Code: [Select]
Fatal error: Call to undefined function template_ic_recent_posts2() in /www/htdocs/xyz/hp_elkarte/sources/Load.php(2612) : eval()'d code on line 377

Point 2 is already in your code, right? I don't have to do anything else then your code changes listed before?

Line 377 is an empty one. I attached my Load.php and my changed BoardIndex.template.php.

Re: Show list of recent topics above board index

Reply #6

Quote from: Jorin – Point 2 is already in your code, right? I don't have to do anything else then your code changes listed before?
Nope. You have to manually do it and from what I can see from your BoardIndex.template.php, you missed it. That basically causes the error. So do change it (line 181) to function template_ic_recent_posts2().

You can view the running sample at ElkArte Malaysia[1]
I made some extra changes in the Curve theme by removing h3 from the code by commenting them out.

Re: Show list of recent topics above board index

Reply #7

Fine, works now. Thanks a lot!  :) 

One small fix is really appreciated: The header line is missing the small arrow on the right whichs shows the expand status.

Re: Show list of recent topics above board index

Reply #8

Sorry about that. I must have mistakeny deleted this &.nbsp;. Find:

Code: [Select]
	 // Here's where the "Recent Posts" starts...
echo '
<div id="info_center" class="forum_category">
<h2 class="category_header">
<span id="category_toggle"> 
Replace it with (adding back that ):
Code: [Select]
	 // Here's where the "Recent Posts" starts...
echo '
<div id="info_center" class="forum_category">
<h2 class="category_header">
<span id="category_toggle"> 

That should fix it.

Re: Show list of recent topics above board index

Reply #9

Wait! That's not my fault. It is ElkArte bug. Please note this @emanuele . This part is missing in the code when posted. I put a dot to make sure you get this: &.nbsp;

I attached a fixed file for you Jorin as the code cannot be properly posted.

Re: Show list of recent topics above board index

Reply #10

Don't wanted to blame you!  :-[  Thanks for your help! All good now!  :)

Re: Show list of recent topics above board index

Reply #11

Quote from: ahrasis – Wait! That's not my fault. It is ElkArte bug. Please note this @emanuele . This part is missing in the code when posted. I put a dot to make sure you get this: &.nbsp;
Yep, there are some problematic combinations hanging around...
Bugs creator.
Features destroyer.
Template killer.


 

Re: Show list of recent topics above board index

Reply #14

I installed the recent topics addon v0.0.4 from here today. And I am wondering. Didn't we fixed the problem that the shown user was the thread starter and not the one who posted the last answer in the thread?

My installation shows the thread starter name. Correct would be the name of the last poster. Help please.  :-[

Correction: I copied the file RecentTopics.class.php from my other board. The addon version there is 0.0.3. With this file it works and shows the correct user name. It seems the version 0.0.4 has lost this...