[thelist] path to an included class file from a template

Matt Warden mwarden at gmail.com
Sat Jul 2 21:27:49 CDT 2005


On 7/2/05, Nan Harbison <nan at heritageconcord.org> wrote:
> 
> Hello,
> I have taken over coding a website that is partially done. The template for
> the website is in a folder called layout/templates and it has references to
> include the header, footer, left and right php files by using references
> such as (DOCPATH_PUBLIC . DIR_INCLUDES . 'header.php') but when I put a
> class file and then try to use the same path, I get this error message:
> 
> 
> Warning: main(/var/www/html/inc/class.inc.php): failed to open stream: No
> such file or directory in /var/www/html/layout/templates/default.tpl.php on
> line 55
> 
> Warning: main(): Failed opening '/var/www/html/inc/class,inc.php' for
> inclusion (include_path='.:/usr/local/lib/php') in
> /var/www/html/layout/templates/default.tpl.php on line 55

Well, this one might have to do with the comma in the file name. I
assume that's a typo.

> So how do I include this file and where do I put it? I don't know anything
> about configuration files. I have been going around and around on this and
> can't figure it out. I don't get this because the template is somehow
> configured to be visible from where it is, but it does not seem to be
> relative to any other folders on the site. Please help!

Well, I'm guessing this isn't going to help you, but: the path you use
in the require() is the path leading to the include file you want to
include. DOCPATH_PUBLIC and DIR_INCLUDES are constants, likely with
values '/var/www/html/', and 'inc/', respectively. If you aren't
storing your files in /var/www/html/inc, you don't want to use these
constants.

If you don't know the absolute path to your include files, you can use
relative paths. If your file is (siteroot)/foo/bar.php and you are
trying to include a file  (siteroot)/inc/class.inc.php, then you could
do require('../inc/class.inc.php'); This is less desirable than using
absolute paths, but it's more desirable than it not working ;-)

-- 
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.


More information about the thelist mailing list