Jan 19, 2015; 12:48
Jussi Hirvi
Defining app root
This is an old question for me, and I still have not found a satisfying
answer. This is L8.6, btw.
Sometimes my app is accessed with http://example.com, and sometimes
https://secure.myserver.com/example.
To get all the includes working I always use relative links, for example
include('inc/defaults.inc');
However, this is not fully satisfying, because some include files should
be accessible from several directory hierarchy levels, and if these
include files in turn have include statements, they will be broken.
WordPress currently uses a solution which seems elegant. In index.php
(app root) they have
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
Where dirname( __FILE__ ) seems to return the parent directory of the
current file (though from the system root, for example
/var/www/example.com/www-site/testdir). If this statement is placed in
an include file, it returns the parent directory of that included file,
NOT of the file that is calling the included file.
Lasso has include_currentpath that could be tailored for this use, but
include_currentpath includes the file name, which should be removed
first using a ctag.
I have also toyed with a variable "approot", but it's clumsy because it
should be defined separately for each "parent file" (files that are
called directly on the browser).
How have you guys solved this problem?
- Jussi
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso Lasso@lists.lassosoft.com
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>