News:

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

Main Menu

Documenting context and context['topics']

Started by neosisani, March 11, 2011, 06:23:12 PM

Previous topic - Next topic

neosisani

Can you please tell me what variables are within struct global context found in nearly all files. I'm especially interested in what struct topic contains.

I'm using SMF 1.1.13

Thanks for your attention

Arantor

$context contains different things in each file, with a few base things that are common, particularly $context['user'] which has a few details for the user.

Better question, what are you trying to do?

neosisani

Add link to last post in topic. Idea so far is to edit MessageIndex.template.php in Themes and add some line in block starting with foreach ($context['topics'] as $topic)

But since I believe I'll have to work around SMF on some other minor customizations I hoped for some more general document to help me on finding my way around.

Arantor

There is no such general document.

Thing is, though, there should already be a link to the last post in the topic in the message index. There certainly is on the default theme - see http://www.simplemachines.org/community/index.php?board=60.0 - the icon on the far right links there.

Really, though, the best way to see what content there is, is to look at the source that builds it - which is MessageIndex.php itself.

neosisani

Thanks Arantor!

Suddenly I feel as if i hadn't done my homework; but my teacher has been merciful and told me the answer anyway instead of RTFM.

I will anyway look at MessageIndex.php to grasp whole code better.

Should I change topic title to something more proper before closing the thread as solved?

Arantor

Well, speaking as someone who spent a lot of time modifying SMF, the biggest problem I hit, repeatedly, is the lack of serious documentation. Yes, there's a function guide which lists all the functions and what parameters they accept, but that's no substitute for knowing what's in the different areas, doubly so in $context (as well as any of the other globals), and the only way I found was to examine what SMF was doing at any given time, in the end I just got familiar with what does what, and just examining the code to get anywhere.

EDIT: I wouldn't worry about changing the title, it is still descriptive.

Advertisement: