Not Solved How does MyBB's template system work?
#1
Not Solved
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?
Reply
#2
Not Solved
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
Reply
#3
Not Solved
Yes but where is it pulling the templates from? The database?
Reply
#4
Not Solved
^ yes, from the database. see class_templates.php
Reply
#5
Not Solved
(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?
Reply
#6
Not Solved
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.
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.
Reply
#7
Not Solved
MyBB 1.8 series does not use a template engine like Blade. MyBB 2.0 will use one.
Reply
#8
Not Solved
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?
Reply
#9
Not Solved
(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
[retired]
Reply
#10
Not Solved
(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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)