Resolve Directory Question

I've read a bunch of threads, but I'm definitely missing something.

Here's my layout:

public_html
->index.php
->modules->directory.php
->views->directory_edit.php

index calls modules which calls views

inside modules/directory.php:
include 'views/directory_edit.php'; <= This doesn't resolve

I've tried:
adding views as a Resource Root in Settings | Directories
adding a constant to provide the absolute path on the remote server rather than the relative path

I haven't tried:
making all paths absolute

Thanks!

1 comment
Comment actions Permalink

Hi Stephane,

In index.php (which is, I assume, your entry point for all URLs), define some constant with current path, e.g.

define('DIR_ROOT', __DIR__);

Then use it with include:

include DIR_ROOT  . '/views/directory_edit.php';

This will make all paths absolute: constant (website root) + relative to the website root folder.

Alternatively, you could try this in your modules/directory.php: (include/require is relative to the current folder first, and only then searching trough include_path):

include '../views/directory_edit.php';
0

Please sign in to leave a comment.