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

Include an external template

Discussion in 'XenForo Questions and Support' started by bart, Mar 20, 2013.

  1. bart

    bart Active Member

    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.
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    What type of template do you want to include?
    You can create your own html templates in the ACP.

    Pages support php callback.
     
  3. bart

    bart Active Member

    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?
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  5. bart

    bart Active Member

    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?
     
  6. Chris D

    Chris D XenForo Developer Staff Member

    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.
     
  7. bart

    bart Active Member

    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.
     
  8. Chris D

    Chris D XenForo Developer Staff Member

    The site in my signature is running around 80 add-ons. You'll be fine.
     
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

Share This Page