Skip to main content
Topic: How these are defined? (Read 2727 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How these are defined?

I am getting undefined error(s) for $context['latest_post']['link'] and $context['latest_post']['time'].

Code: [Select]
<p class="inline">
', $context['common_stats']['boardindex_total_posts'], '', !empty($settings['show_latest_member']) ? ' - ' . $txt['latest_member'] . ': <strong> ' . $context['common_stats']['latest_member']['link'] . '</strong>' : '', ' - ', $txt['most_online_today'], ': ', comma_format($modSettings['mostOnlineToday']), '<br />
', (!empty($context['latest_post']) ? $txt['latest_post'] . ': <strong>"' . $context['latest_post']['link'] . '"</strong>  ( ' . $context['latest_post']['time'] . ' )' : ''), ' - <a href="', $scripturl, '?action=recent">', $txt['recent_view'], '</a>
</p>

I can find $context['latest_post'] but how $context['latest_post']['link'] and $context['latest_post']['time'] are defined?

$context['latest_post'] is defined:
Code: [Select]
		// Retrieve the categories and boards.
require_once(SUBSDIR . '/BoardsList.class.php');
$boardIndexOptions = array(
'include_categories' => true,
'base_level' => 0,
'parent_id' => 0,
'set_latest_post' => true,
'countChildPosts' => !empty($modSettings['countChildPosts']),
);
$boardlist = new Boards_List($boardIndexOptions);
$context['categories'] = $boardlist->getBoards();
$context['latest_post'] = $boardlist->getLatestPost();

Any heads up?

My temporary solution is checking whether those $context['latest_post']['link'] and $context['latest_post']['time'] are empty instead.

Code: [Select]
					', (!empty($context['latest_post']['link']) && !empty($context['latest_post']['time']) ? $txt['latest_post'] . ': <strong>"' . $context['latest_post']['link'] . '"</strong>  ( ' . $context['latest_post']['time'] . ' )' : ''), ' - <a href="', $scripturl, '?action=recent">', $txt['recent_view'], '</a>

Should this be fine?
Last Edit: February 03, 2015, 10:57:12 am by ahrasis

Re: How these are defined?

Reply #1

Where are you getting these errors?
I seem to remember something similar already reported, but that I was unable to pinpoint.

Yes, here it is: http://www.elkarte.net/community/index.php?topic=2027.0
http://www.elkarte.net/community/index.php?topic=1857.0

Looking at the code, it looks like it is related to a...
AHA!
Got it.
When all the categories are collapsed, the array is not set to the board, but just to a piece of it and hence the error.
Try with this change
In BoardIndex.class.php search:
Code: [Select]
		if (empty($this->_latest_post))
and replace it with:
Code: [Select]
		if (empty($this->_latest_post) || empty($this->_latest_post['link']))
Last Edit: February 03, 2015, 04:29:58 pm by emanuele
Bugs creator.
Features destroyer.
Template killer.


Re: How these are defined?

Reply #3

I think you mean BoardsList.class.php. But I haven't try your solution as it doesn't mention about $context['latest_post']['time'] which is also undefined. Will your solution covers that too or just the $context['latest_post']['link'] undefined error?

Edited - Attempted the suggested fix. So far there is no undefined error for both $context. Will update if there is any.
Last Edit: February 04, 2015, 12:37:42 am by ahrasis

Re: How these are defined?

Reply #4

Yep, sorry!
I mixed BoardIndex.template.php with BoardsList.class.php... :-[
Bugs creator.
Features destroyer.
Template killer.