News:

Wondering if this will always be free?  See why free is better.

Main Menu

The $context Array

Started by Jade Elizabeth, January 02, 2015, 10:29:27 AM

Previous topic - Next topic

Jade Elizabeth

So I understand the $context array is rather huge and used everywhere. I'm adding a whole new section to SMF that is quite enormous as it is...should I be loading all of my stuff into it or might it be a better idea to use my own section variable? I know it's only used in this area but I've filled it with quite a lot of info collecting categories, types and subtypes and I'm about to do it again now loading a huge amount of info about works to put that on the page.

Or am I completely misunderstanding what it's used for and using it correctly? I'm just worried I might make it too huge?
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Arantor

$context is a huge array that exists everywhere at any given time. Anything you want to get from Sources to templates needs to go via $context.

You're going to be putting everything into it anyway, the only question is whether you put it directly into $context or into a subsection, e.g. $context['works']. And that one is mostly up to you and mostly a question of aesthetic.

Jade Elizabeth

I have definitely put it into a subsection, I just didn't want to overload things and make it slower. That answers my question though :D. Thank you!
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Arantor

The amount of difference it makes is so small it's not worth worrying about.

Advertisement: