News:

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

Main Menu

Where to invoke a function?

Started by captcha, April 02, 2020, 04:23:52 PM

Previous topic - Next topic

captcha

I do not understand SMF's template system yet. The php template engine that I have used will finally render the templates.
I know SMF's template file include functions will echo the context,  there are only functions defined  but not called. What's the mechanism of SMF to invoke a function.
I read index.php, the function smf_main() will return a name of Function_tobe_called. Where in the source code to call smf_main(), and how to let a function name excute?
Thanks a ot in advance.

Shambles

Not sure I fully understand your query.


QuoteWhere in the source code to call smf_main(), and how to let a function name excute?

In your index.php you should be able to see this:


// What function shall we execute? (done like this for memory's sake.)
call_user_func(smf_main());

Ricky.

You should start here :
https://wiki.simplemachines.org/smf/Creating_and_Understanding_Themes

It will not answer all of your questions but will get some basic idea.

For question, if you really want to understand then you have to study the code, start with index.php and follow it.

May be see this first to get a quick idea about flow in SMF :
https://wiki.simplemachines.org/smf/Add_a_custom_action   



captcha

Quote from: Shambles on April 02, 2020, 04:46:39 PM
Not sure I fully understand your query.


QuoteWhere in the source code to call smf_main(), and how to let a function name excute?

In your index.php you should be able to see this:


// What function shall we execute? (done like this for memory's sake.)
call_user_func(smf_main());

Thank you very much, I found call_user_func(smf_main()) before the function declaration. Now I see the mechanism of index.php.
Still confused on the template system, I have read the manual on it. I mean the rendering mechanism, not how to create my own template. 

captcha

After I read more source codes, I understand how to render the template now:
loadTheme()->loadTemplate()->template_include()

Advertisement: