Customizing SMF > Graphics and Templates
How to remove category from link tree?
hellodarren1:
I want to remove the category from the link tree so that instead of:
Site > General Category > General Forum
It reads:
Site > General Forum
I did a search but couldn't find anything that worked, thanks.
Akyhne:
It's not a theme change. It's located in Load.php
Find:
--- Code: --- // Build up the linktree.
$context['linktree'] = array_merge(
$context['linktree'],
array(array(
'url' => $scripturl . '#c' . $board_info['cat']['id'],
'name' => $board_info['cat']['name']
)),
array_reverse($board_info['parent_boards']),
array(array(
'url' => $scripturl . '?board=' . $board . '.0',
'name' => $board_info['name']
))
);
--- End code ---
Replace with:
--- Code: --- // Build up the linktree.
$context['linktree'] = array_merge(
$context['linktree'],
array_reverse($board_info['parent_boards']),
array(array(
'url' => $scripturl . '?board=' . $board . '.0',
'name' => $board_info['name']
))
);
--- End code ---
hellodarren1:
Oh I was really hoping I could keep this change restricted to the theme. I did find this topic which shows how to do it via themes but it's for SMF 1.0. I did try it on 2.0 and it removed the category when viewing posts, but it also removed the topic title and had no effect on the page that displays all the topics.
Akyhne:
Well, try with this:
In Index.template.php in the theme, find:
--- Code: --- // Each tree item has a URL and name. Some may have extra_before and extra_after.
foreach ($context['linktree'] as $link_num => $tree)
{
echo '
<li', ($link_num == count($context['linktree']) - 1) ? ' class="last"' : '', '>';
// Show something before the link?
if (isset($tree['extra_before']))
echo $tree['extra_before'];
// Show the link, including a URL if it should have one.
echo $settings['linktree_link'] && isset($tree['url']) ? '
<a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>' : '<span>' . $tree['name'] . '</span>';
// Show something after the link...?
if (isset($tree['extra_after']))
echo $tree['extra_after'];
// Don't show a separator for the last one.
if ($link_num != count($context['linktree']) - 1)
echo ' »';
echo '
</li>';
}
--- End code ---
replace with:
--- Code: --- global $board_info;
// Each tree item has a URL and name. Some may have extra_before and extra_after.
foreach ($context['linktree'] as $link_num => $tree)
{
if(isset($board_info['cat']) && $tree['name'] !== $board_info['cat']['name'])
{
echo '
<li', ($link_num == count($context['linktree']) - 1) ? ' class="last"' : '', '>';
// Show something before the link?
if (isset($tree['extra_before']))
echo $tree['extra_before'];
// Show the link, including a URL if it should have one.
echo $settings['linktree_link'] && isset($tree['url']) ? '
<a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>' : '<span>' . $tree['name'] . '</span>';
// Show something after the link...?
if (isset($tree['extra_after']))
echo $tree['extra_after'];
// Don't show a separator for the last one.
if ($link_num != count($context['linktree']) - 1)
echo ' ยป';
echo '
</li>';
}
}
--- End code ---
hellodarren1:
Wow thanks that worked almost flawlessly. The only problem is that the forum name in the link tree disappears when you're viewing the forum index.
Navigation
[0] Message Index
[#] Next page
Go to full version