ElkArte Community

Elk Development => Theme development => Topic started by: Jorin on May 12, 2015, 01:57:31 am

Title: Show list of recent topics above board index
Post by: Jorin on May 12, 2015, 01:57:31 am
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.  :(
Title: Re: Show list of recent topics above board index
Post by: ahrasis on May 12, 2015, 02:07:13 am
Manual changes or using hook?
Title: Re: Show list of recent topics above board index
Post by: Jorin on May 12, 2015, 02:15:07 am
What's better? I tried manual changes in the files.
Title: Re: Show list of recent topics above board index
Post by: ahrasis on May 12, 2015, 02:24:28 am
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();
}
Title: Re: Show list of recent topics above board index
Post by: ahrasis on May 12, 2015, 03:03:28 am
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. :)
Title: Re: Show list of recent topics above board index
Post by: Jorin on May 13, 2015, 01:37:59 am
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.
Title: Re: Show list of recent topics above board index
Post by: ahrasis on May 13, 2015, 02:15:01 am
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 (http://elkarte.sch.my)[1]
I made some extra changes in the Curve theme by removing h3 from the code by commenting them out.
Title: Re: Show list of recent topics above board index
Post by: Jorin on May 13, 2015, 02:26:22 am
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.
Title: Re: Show list of recent topics above board index
Post by: ahrasis on May 13, 2015, 02:54:33 am
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.
Title: Re: Show list of recent topics above board index
Post by: ahrasis on May 13, 2015, 02:58:31 am
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.
Title: Re: Show list of recent topics above board index
Post by: Jorin on May 13, 2015, 02:59:38 am
Don't wanted to blame you!  :-[  Thanks for your help! All good now!  :)
Title: Re: Show list of recent topics above board index
Post by: emanuele on May 13, 2015, 04:02:20 am
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...
Title: Re: Show list of recent topics above board index
Post by: emanuele on May 26, 2015, 03:59:12 pm
xref: http://www.elkarte.net/community/index.php?topic=2643.msg17918#msg17918 O:-)
Title: Re: Show list of recent topics above board index
Post by: ahrasis on May 26, 2015, 10:45:11 pm
Quote from: emanuele – xref: http://www.elkarte.net/community/index.php?topic=2643.msg17918#msg17918 O:-)
Installed but not working. Recent posts still below. No errors. Any ideas?
Title: Re: Show list of recent topics above board index
Post by: Jorin on July 11, 2015, 02:20:16 am
I installed the recent topics addon v0.0.4 from here (http://addons.elkarte.net/2015/02/Recent-Topics/) 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...
Title: Re: Show list of recent topics above board index
Post by: emanuele on July 11, 2015, 11:39:06 am
As far as I can tell the one there should show the data of the last message, I'll try it out again later.
Title: Re: Show list of recent topics above board index
Post by: ahrasis on August 16, 2016, 09:43:46 am
I can't get the addon to work until now but at least the edit to BoardIndex.template.php still works.
Title: Re: Show list of recent topics above board index
Post by: gevv on November 13, 2016, 07:37:06 am
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;

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

Hi,

BoardIndex.template.php What should be changed for 1.1B3 ?

Title: Re: Show list of recent topics above board index
Post by: ahrasis on November 13, 2016, 09:28:59 am
Reply #4. Please note the missing &.nbsp; too.
Title: Re: Show list of recent topics above board index
Post by: emanuele on November 13, 2016, 04:52:46 pm
You can install the addon I linked here (http://www.elkarte.net/community/index.php?topic=2631.msg17919#msg17919), I just fixed a typo that was breaking the package.
Also, if you want the topic and not the posts, you'd need this addon (http://addons.elkarte.net/enhancement/Recent-Topics.html) until my open PR is merged (because in that PR I finally fixed the "show recent topics" code that was broken since forever).