variable to reference root dir in template files?

Discussion in 'Templates customization' started by sdstren, Mar 4, 2008.

  1. sdstren

    sdstren New Member

    Joined:
    Nov 30, 2007
    Messages:
    14
    I submitted a ticket for this as well, but I am hoping perhaps someone here can help me as well.

    I need to know how to manipulate my file paths in my header.html file so that they will work no matter where they are called from.

    I know just enough to be dangerous. Can you please help me figure out how to do this? My header file has a couple of include lines in it:

    <?php include("/webfiles/loadmenu.js"); ?>

    and

    <?php include("/webfiles/topmenu.htm"); ?>


    topmenu.htm in turn has several href and img src statements in it.

    My problem is that all of this works while I am using any /amember/tempates/*.html files, but it crashes when header.html is called from anywhere else, like a payment processor.

    I know very little about php or smarty, and only use what I've been able to pickup via monkey see monkey do.

    Can you kindly tell me how to use a variable that both php and smarty will recognize to specify the root directory so that I can use an absolute path in both of my include statements and in my href and img statements? I tried just using / at the beginning of the references, but I get all kinds of crazy error messages. when I use a relative path, like ../webfiles it works in the amember/template/*.html files, but not for payment processing.

    This is probably a very simple thing for someone with experience. I just can't seem to figure it out and its driving me nuts.

    Thanks

    Sandi
  2. tomfra

    tomfra Member

    Joined:
    Dec 21, 2006
    Messages:
    199
    Use this:

    <?php include($_SERVER['DOCUMENT_ROOT']."/webfiles/loadmenu.js"); ?>

    and

    <?php include($_SERVER['DOCUMENT_ROOT']."/webfiles/topmenu.htm"); ?>

    instead. $_SERVER['DOCUMENT_ROOT'] may not work correctly on some servers but there is a workaround so let me know if it does not.

    Tomas
  3. sdstren

    sdstren New Member

    Joined:
    Nov 30, 2007
    Messages:
    14
    Tomas you are my hero!

    That worked beautifully!

    Thanks

    Sandi

Share This Page