Jump to the post that solved this thread.
Solved: 4 Years, 6 Months, 3 Weeks ago New Template Not Showing Up
#1
Solved: 4 Years, 6 Months, 3 Weeks ago
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}
Reply
#2
Solved: 4 Years, 6 Months, 3 Weeks ago
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.
My Projects - Support My Projects

Don't forget to rate posts!
Reply
#3
Solved: 4 Years, 6 Months, 3 Weeks ago
Make sure that the template has not gone into global templates as it's a plugin that added the template.
Check out all my submissions here - click me
MyBB support at it's finest. 
Reply
#4
Solved: 4 Years, 6 Months, 3 Weeks ago
@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.
Reply
#5
Solved: 4 Years, 6 Months, 3 Weeks ago
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.
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.
Reply
#6
Solved: 4 Years, 6 Months, 3 Weeks ago
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?
Reply
#7
Solved: 4 Years, 6 Months, 3 Weeks ago
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.


Attached Files
.php   index_affiliates.php (Size: 739 bytes / Downloads: 59)
MyReactions - All Plugins

Can you still feel the butterflies?

Free never tasted like pudding.
Reply
#8
Solved: 4 Years, 6 Months, 3 Weeks ago
Thanks! Smile
Reply
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)