Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Include php header in tpl

  1. #1
    Join Date
    Nov 2007
    Location
    USA
    Posts
    154

    Default Include php header in tpl

    I am trying to include the php header from my wordpress in order to replace the header on whmcs. I have removed the whmcs header and background but it doesn't seam to be displaying my wordpress header.php....am I missing something? Can I include php in the tpl file?

  2. #2
    Join Date
    Oct 2007
    Posts
    68

    Default

    Whats the include code you are using?
    If you are using <?php ?> tags, replace these with {php} and {/php} respectively.
    Eg:
    Code:
    {php}include ('../head.php');{/php}

  3. #3
    Join Date
    Nov 2007
    Location
    USA
    Posts
    154

    Default

    thanks robbo. I tried that and instead get a complete blank white page (I cleared out my templates_c)
    this is my code:
    {php}include ('../wp-content/themes/hosting/header.php');{/php}

  4. #4
    Join Date
    Oct 2007
    Posts
    68

    Default

    Are you able to tell me where the 2 sites (WHMCS and Wordpress) are located?

    The ../ at the front is just what mine has (the head.php is located one directory above my WHMCS)

    Sounds like it can't find the file, so it spits out a blank page which is normal for the WHMCS system.

  5. #5
    Join Date
    Nov 2007
    Location
    USA
    Posts
    154

    Default

    Quote Originally Posted by robbo View Post
    Are you able to tell me where the 2 sites (WHMCS and Wordpress) are located?

    The ../ at the front is just what mine has (the head.php is located one directory above my WHMCS)

    Sounds like it can't find the file, so it spits out a blank page which is normal for the WHMCS system.
    Certainly robbo.
    public_html/wp-content/themes/hosting/header.php --is where my header is located
    public_html/clients/templates/portal/header.tpl --is the header for my whmcs

    I'm also noticing, my wordpress displays just fine on my index page, but when trying to access the header this way: Here I am noticing I get an error..Would this make any difference? The header displays absolutely fine on my site, so I wouldn't think it would make a difference..

    Thanks for your help robbo!

  6. #6
    Join Date
    Oct 2007
    Posts
    68

    Default

    It looks like that could be causing the error.
    Possibly try, {php}include ('/home/user/public_html/wp-content/themes/hosting/header.php');{/php}

    Replace /home/user with your full address. This will rule out it not finding the file. If it doesn't work, you might just have to copy the source code and paste into the header.tpl

    Good luck.

  7. #7
    Join Date
    Nov 2007
    Location
    USA
    Posts
    154

    Default

    Thanks alot robbo. going to try that now! Would I also need the css information too if I copy the whole header file?

  8. #8
    Join Date
    Oct 2007
    Posts
    68

    Default

    Yes you would, as there will be certain styles in the main page which aren't in the WHMCS template styles.

  9. #9
    Join Date
    Nov 2007
    Location
    USA
    Posts
    154

    Default

    Quote Originally Posted by robbo View Post
    Yes you would, as there will be certain styles in the main page which aren't in the WHMCS template styles.
    Thanks bud, still didn't work so i'm not exactly sure what I am gonna do. the furthest i've gotten was the original way, which gave me a white screen and all that shows up is the code upto the first bloginfo which is:
    <meta http-equiv="Content-Type" content="

    I am thinking it must be because of the error I am getting in my header.php..It's really weird that the error shows up even though the header displays perfectly fine on my main page..

  10. #10
    Join Date
    Jun 2008
    Location
    Kansas
    Posts
    102

    Default

    for anyone trying to do this, just including the header.php file won't work, because it's not initializing the wp variables, etc. that way.

    i found an approach that worked for me here - http://bloke.org/php/using-wordpress...rs-externally/

  11. #11
    Join Date
    Oct 2008
    Posts
    49

    Default

    Not a coder, just an idea from my own design troubles...

    Copy the contents of your header file into another file local to your WHMCS directory, change the include calls in the new file you created, and use {literal} {/literal} tags at the start and end of that file?

  12. #12
    Join Date
    Feb 2012
    Posts
    3

    Default

    Trying to do the same and I will update you.

    @mycommon No, Literal tags are used for java script.

  13. #13
    Join Date
    Feb 2009
    Location
    Atlanta, GA
    Posts
    1,683

    Default

    Quote Originally Posted by HostXLarge View Post

    @mycommon No, Literal tags are used for java script.
    Literal tags are used for anything you want to escape from normal smarty markup. Specifically { and } characters. If you anticipate having any of them in normal text or code, you either need to wrap {literal} tags around it, or replace them with {ldelim} and {rdelim}

    Its not only for javascript, but thats commonly where you will see it.

  14. #14
    Join Date
    Apr 2010
    Location
    Athens
    Posts
    72

    Default

    You can use
    Code:
    {include_php file='/path/file.php'}
    Cubric Internet Services
    Web Hosting, Design & Development
    www.cubric.gr

  15. #15
    Join Date
    Apr 2010
    Location
    United States
    Posts
    30

    Default Re: Include php header in tpl

    An include isn't actually the best way to do this. I have a method that works a bit cleaner. Works with Joomla / WordPress, I'll post it if you wish.

Page 1 of 2 12 LastLast

Similar Threads

  1. header.tpl to header.php
    By milestonemedia in forum General Discussion
    Replies: 1
    Last Post: 06-28-10, 09:27 PM
  2. How to include a php file inside tpl
    By vertigos in forum Customisation & Integration Questions
    Replies: 8
    Last Post: 01-09-09, 11:14 AM
  3. How to PHP include a TPL? LOST!
    By xtel in forum Customisation & Integration Questions
    Replies: 5
    Last Post: 04-23-08, 08:32 PM
  4. php tpl include
    By dannzegos in forum Customisation & Integration Questions
    Replies: 8
    Last Post: 01-18-08, 02:51 AM