News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Display Board List on All Pages

Started by Stanyy, September 30, 2014, 12:38:08 PM

Previous topic - Next topic

Stanyy

I have a few boards and I am trying to get them to display on a single line on all pages of the forum so my users can easily navigate through the forum. But sadly, the code I got from boardindex.template.php only works on the home page and not on other pages. I have no idea why.


echo'<div>';
foreach ($context['categories'] as $category)
{


// Assuming the category hasn't been collapsed...
if (!$category['is_collapsed'])
{


$i = 0;
foreach ($category['boards'] as $board)
{


echo'
<a href="', $board['href'], '">', $board['name'], '</a>', ' | ';




}

}

}
echo'</div>';

Arantor

Because the data for $context['categories'] isn't fetched every single page for performance reasons?

margarett

Yes, that's only fetched at Board Index.

Thinking loud about it, it should be possible to fetch (with cache!) in Load.php and have it available in another $context item. Not sure about the implications of that, though (permissions and stuff).
Another simple way of doing it is to hard code all the boards list/url in index.template.php so that they are shown everywhere without further database load. The backside of this is that it wouldn't be dynamic...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Stanyy

#3
Quote from: Arantor on September 30, 2014, 12:38:58 PM
Because the data for $context['categories'] isn't fetched every single page for performance reasons?
If it isn't Performance my long time foe. :D

I actually want it to be shown to logged members only.
Also while trying to make the forum responsive, I've thinned down the whole thing a lot and killed off a bunch of functionality, deleted the original board index and hard coded the menu.. I believe (could be wrong) this one won't have that much noticeable impact.
Quote from: margarett on September 30, 2014, 12:41:25 PM
Yes, that's only fetched at Board Index.

Thinking loud about it, it should be possible to fetch (with cache!) in Load.php and have it available in another $context item. Not sure about the implications of that, though (permissions and stuff).
Another simple way of doing it is to hard code all the boards list/url in index.template.php so that they are shown everywhere without further database load. The backside of this is that it wouldn't be dynamic...
Thanks, I actually want it to be dynamic because I already have a hard-coded forum menu to deal with and don't want to complicate things further. :/
I don't think I've been in Load.php before so I'm completely clueless here :/
A guidiance will be appreciated.

Arantor

The problem is the actual data gathering is surprisingly complex which is why there is already an exclusion on sub-boards-of-sub-boards being considered properly.

Stanyy

Quote from: Arantor on September 30, 2014, 01:26:43 PM
The problem is the actual data gathering is surprisingly complex which is why there is already an exclusion on sub-boards-of-sub-boards being considered properly.

Hi, what about the jumpto box showing beneath all boards and topics? Does it have a context I can use instead?

Arantor

No because it's not actually loaded all the time. It only loads when you click on it. And for *exactly* the same reason.

Advertisement: