MyBB Community Forums

Full Version: How does MyBB's template system work?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I understand that the templates are loaded into the database under "mybb_templates", but how does MyBB call them and where do they place them at?

Is it similar to "mybb_settings", where it stores all the variables in a php file and calls them by their variable names?

I ask this because I've noticed this line of code in a lot of pages:
$templatelist .= ",multipage,multipage_end,multipage_jump_page,multipage_nextpage,multipage_page,multipage_page_current,multipage_page_link_current,multipage_prevpage,multipage_start,portal_announcement_send_item,portal_announcement_icon,portal_announcement_avatar,portal_announcement_numcomments";

Correct me if I am wrong, but this is calling certain template files so they aren't all loaded. But what exactly is it pulling this from?
basically eval & output_page functions are used in the php files to get & display contents

eg. index.php file
eval('$index = "'.$templates->get('index').'";');
output_page($index);

a brief about templates system => templates

you may be interested in plugins guidance - creating a new page
Yes but where is it pulling the templates from? The database?
^ yes, from the database. see class_templates.php
(2017-02-13, 03:50 AM).m. Wrote: [ -> ]^ yes, from the database. see class_templates.php

Thank you very much for the link provided. I have one more question, is the template system on MyBB cached?
By default they're "cached" per-request (i.e. they're all loaded in one query not one for each template), they're not cached between requests.
MyBB 1.8 series does not use a template engine like Blade. MyBB 2.0 will use one.
I mean don't they technically have one? It's just they are using their own?

BTW, I was also wondering, how does MyBB's language files work? Is it just all stored in PHP under variables?
(2017-02-14, 06:57 PM)Achilles Wrote: [ -> ]...how does MyBB's language files work? Is it just all stored in PHP under variables?

Yes.

Each language file is a PHP file that stores each language entry as:

$l['variable_name'] = 'content';

...so they can be used like:

$lang->variable_name
(2017-02-14, 06:57 PM)Achilles Wrote: [ -> ]I mean don't they technically have one? It's just they are using their own?

Basically templates are just eval'd. A couple minor spots in the templates have replacements such as the debug stuff in the footer but that's basically it. It certainly is far from ideal, but its too big of change to do in 1.8.
Pages: 1 2