php includes path question

I'm using some includes that I've written. So far, I seem to only be able to get them recognized by using paths like this one:

include ('/home/stanatsc/public_html/gal01/themes/defjam_exie/php_includes/slideshow_extra_functions.php');

Obviously, it would be MUCH better to use variables, but I can't seem to get them to work. For example, I've tried using $_zp_themeroot, but with no luck.

What is the proper syntax for doing this and what variables are recommended?

Thanks in advance!

Comments

  • The defines you are looking for are:
    `SERVERPATH`, `ZENFOLDER`, `PLUGIN_FOLDER`, and `THEMEFOLDER`

    `$_zp_themeroot` should be setup for any script that is loaded by the zenphoto root index.php script. What are you finding with it?

    What you actually have to use will depend on where the include is located. Standard OS file referencing applies, so if the script is in the same folder as the one to be included all you need is the script name. If the included script is in a subfolder then the path is «subfolder»/«script name», etc.
  • Okay - I think I understand now. $_zp_themeroot will only work from the appropriate location. that makes sense. thanks!
  • argh. still confused by this. what do i have to do to an included php file such that I can use $_zp_themeroot in that file?
  • If it is not setup for you, you will have to manually set it up.
    `$_zp_themeroot = WEBPATH . "/" . THEMEFOLDER . "/" . $ThemeName;`
  • Hmm... I think I must still be having novice issues. When I define a variable as you've described, WEBPATH and THEMEFOLDER don't appear as variables. I'm afraid my newness to PHP is probably interfering here. What do I have to do to make WEBPATH and THEMEFOLDER and $ThemeName work correctly (in, for example) a php file that I am including.

    Thanks in advance, and if this question is just too basic and stupid to answer, I totally understand. :(
  • acrylian Administrator, Developer
    So you are trying to include files directly from within the theme folder? I actually do that for example on the zenpage project site direclty with `include("file.php");`or `require_once("file.php");` without any theme path variable.
  • WEBPATH, etc. are defined in functions-basic.php. So, if you are finding them not defined then nothing from zenphoto has been loaded. So, I think we need to reset this discussion back to basics.

    What exactly are you tring to accomplish? Is all this happening in PHP scripts in your theme? Then you can use un-qualified filenames as acrylian has shown above.
  • things i'm trying to accomplish:
    -including files (residing in the theme folder) so that they'll work if i move them to another theme (so calling them via relative paths and/or THEMEFOLDER would be great)
    -referencing images (also in the theme folder)

    i haven't had much luck with the relative path approach, so i was hoping to use the THEMEFOLDER approach, but i think i must be using that variable incorrectly. i'll try to find it in another file and copy its use and see if i can accomplish this.

    thanks for helping a php novice!
  • If you are always doing this from a script that is also in the theme folder, then the best way is to just use the relative paths. So if your sructure is:

    Theme
    --images
    ----image1.jpg
    --css
    ----style1.css
    --scripts
    ----script1.php
    --theme.php
    --script2.php

    Then from theme.php you can reference the other files as:

    script2.php
    css/style1.css
    images/image1.jpg

    from script1.php the references would be

    ../script2.php
    ../css/style1.css
    ../images/image1.jpg
  • yes, that's what i tried, but perhaps i just miscalculated somewhere. i'll go back and have a look at it more carefully. perhaps it is a simple syntax error problem (hopefully). anyways, thanks much for the support - i appreciate it!
Sign In or Register to comment.