Uutiset:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu
Advertisement:

Manually adding a sidebar with content from a separate file

Aloittaja triom, syyskuu 19, 2013, 11:13:51 AP

« edellinen - seuraava »

triom

Hi all,

I'm using the SMF default Curve theme on brand new SMF 2.0.5 and want to add a sidebar.  I don't want to use a portal so it seems I need to edit some of the templates.

In order to add a sidebar to those templates (BoardIndex, MessageIndex, Display), it looks like I need to add/modify tables.

After I modify the templates, I'd like the content for the sidebar to come from a separate file (e.g., sidebar.php); so that I can modify the sidebar one and have it updated on all the templates. 

Is this a reasonable approach?

kat

Out of curiosity, why don't you want a portal?

Simple Portal, for one, has "Integration" mode. "This will disable the portal page. Blocks are only usable in forum". Which seems to be what you want.

It'll save you a lot of messing around, kinda reinventing the wheel, as it were... ;)

IchBin™

If you don't want the overhead of a portal, you only need to put your sidebar in the index.template.php file.  You get your sidebar the way you want it, then just add your include('path/to/sidebar.php'); in the index template to put the sidebar in there.
IchBin™        TinyPortal

Arantor

Only that would load on every page, and not just the specified pages...

Yes, it is possible to put a sidebar onto just the specified pages by modifying their templates, but it's unpleasant, as it involves wrapping content around the existing content to ensure the container flows properly. A portal mod does already cover this stuff off already.
Holder of controversial views, all of which my own.


IchBin™

Lainaus käyttäjältä: Arantor - syyskuu 19, 2013, 08:30:35 IP
Only that would load on every page, and not just the specified pages...

Yes, it is possible to put a sidebar onto just the specified pages by modifying their templates, but it's unpleasant, as it involves wrapping content around the existing content to ensure the container flows properly. A portal mod does already cover this stuff off already.

I agree a portal mod does this. But a portal mod isn't for everybody. Especially if all they want are one or 2 things from a portal.

It's easy enough to code it for certain actions or conditions. Just throwing the additional option out there so the user knows.
IchBin™        TinyPortal

triom

Thanks for the quick and helpful replies!  I want to avoid using a portal because I don't think I need those features and I want to try to stick to the stock SMF as much as possible.  If there was a way for me to add a sidebar without modifying too much code, then I thought that would be easier to maintain. 

I will install Simple Portal on my test site and check it out.  I will also try playing with the index template to add a sidebar to see how easy it is. 

Thanks again for the pointers!

triom

As I'm modifying code to add a sidebar.. is it possible to detect what template is being display and change what is seen?

So.. within index.template.php.. I will load the contents of sidebar.php.  In sidebar.php, can I say display X if viewing the Board Index, and display Y if viewing a forum thread?

Arantor

That's why you don't do it in index.template.php as I already kind of pointed out... index.template.php has no reliable knowledge of what page it is displaying.

You're actually better putting it directly into the templates of the pages you want rather than all of them (note that the portal mods have subsystems geared around this stuff already)
Holder of controversial views, all of which my own.


triom

Thanks for quick answer.  As I understand my needs better, it may indeed make sense to go with a portal mod.

triom

Well, I spent a few hours messing with the templates and learned a little about how they work.  I also tried out Simple Portal and saw how easy it was to configure sidebars and use Integration mode.  I was happy to see that it worked fine with the default theme and have decided to use it. 

Thanks for all the advice and your patience.  ;)

kat

Worth thinking hard, before trying to reinvent the wheel. ;)

Glad you're sorted, mate. :)

Advertisement: