MyBB Community Forums

Full Version: New Template Not Showing Up
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've always had the problems of new templates I create anywhere never showing up, so usually I just edit what is supplied.

However, I'd like to go ahead and add in a new template. I tried, I failed, somethings wrong or I'm doing something incorrectly because I have no idea what I'm doing.

SITE LINK: 
http://edherest.sunwolves.com/index.php

NEW TEMPLATE NAME:
index_affiliates

WHERE IS TEMPLATE GOING:
inside Index Templates --> Index

CODE I PLACED IN INDEX:
{$index_affiliates}
You need to add this php code in the index.php to load the template:
eval('$index_affiliates = "'.$templates->get('index_affiliates').'";')

You should place it before the load of index template.
Make sure that the template has not gone into global templates as it's a plugin that added the template.
@chack1172
I added that code in the top right above this:
$templatelist = "index,index_whosonline,index_whosonline_memberbit,forumbit_depth1_cat,forumbit_depth2_cat,forumbit_depth2_forum,forumbit_depth1_forum_lastpost,forumbit_depth2_forum_lastpost,forumbit_moderators";
$templatelist .= ",index_birthdays_birthday,index_birthdays,index_logoutlink,index_statspage,index_stats,forumbit_depth3,forumbit_depth3_statusicon,index_boardstats,forumbit_depth2_forum_lastpost_never,forumbit_depth2_forum_viewers";
$templatelist .= ",forumbit_moderators_group,forumbit_moderators_user,forumbit_depth2_forum_lastpost_hidden,forumbit_subforums,forumbit_depth2_forum_unapproved_posts,forumbit_depth2_forum_unapproved_threads";
BUT when saved, the site wouldn't even load, did I place it in the incorrect area?

------------
@Nasyr
It is in the correct template area for this theme and its templates.
That's just caching the template for the query to load them, as chack1172 said you need some PHP to actually render the template.

I wouldn't recommend editing core files to do this, you'd be better off with a basic plugin to define the variable instead.
Can I be directed to a plugin to do this?

Why would you be allowed to create new templates if they can't even be used without an additional plugin?

Or is this just a weird problem on my end?
No, it's because when you put something like {$index_affiliates} in a template, $index_affiliates is a PHP variable that has been/needs to be defined somewhere, and it doesn't know it's supposed to contain the HTML from a template of the same name unless you tell it that's what it's supposed to contain. The PHP variable isn't automatically generated, you need to define it.

Try the attached, upload to ./inc/plugins/ and activate in the ACP.
Thanks! Smile