• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Include an external template

bart

Active member
#1
Is it possible to include an external template?

Or is there another way to import an template i make with another program? It could reside in the xenforo-directory and would be html.

And yet another step further: can I include a php-script on a page. I would like it to be precessed in category-view with the category-id as a parameter and it would output html to be inserted in the page.
 

Brogan

XenForo moderator
Staff member
#2
What type of template do you want to include?
You can create your own html templates in the ACP.

Pages support php callback.
 

bart

Active member
#3
i want to add some html i make in a different program. non-xenforo. I would like to be able to read in the file and insert it in - for example - category_view.

I am actually trying to migrate to xenforo and keep using some of my old scripts. I need to find a way to get the output of those scripts inside xenforo.

Do I make sense?
 

bart

Active member
#5
I already got that to work because of Kier's video. I was trying to get this include in a forumpage, not in a "page". In category-view. Or forum-view. But it doesn't seem to be possible without an add-on.

Different way to put the question: is there a way to edit a template directly in the database (through phpmyadmin or such) and have the result shown in xenforo instantly?
 

Chris D

XenForo developer
Staff member
#6
I already got that to work because of Kier's video. I was trying to get this include in a forumpage, not in a "page". In category-view. Or forum-view. But it doesn't seem to be possible without an add-on.

Different way to put the question: is there a way to edit a template directly in the database (through phpmyadmin or such) and have the result shown in xenforo instantly?
You're right. It isn't possible without an add-on.

And no, unfortunately not. There's different stages of templates in XenForo ranging from the basic template syntax all the way through to compiled templates which is the basic template that has been compiled into the raw PHP used to render pages. It certainly wouldn't be advisable to directly edit compiled templates.

Your best bet is to look for a tutorial detailing how to use template hooks. Kier has a video and there's a couple of text based ones in the Resource Manager. This will allow you to use PHP to inject HTML into templates. So you could include your PHP script and render its output directly into an existing template.
 

bart

Active member
#7
Thanks for your reply.

I haven't really looked into the hooks-part yet. Guess I'll do that. But I'm a bit weary about that. There are already 76 files read for every page one sees. With only a few add-ons active. I wonder if it will all keep working when ist's showtime.