<![CDATA[ Dealing with includes - My Forums]]> https://forums.modx.com/thread/?thread=33426 <![CDATA[Re: Dealing with includes]]> https://forums.modx.com/thread/33426/dealing-with-includes#dis-post-183838 Quote from: OpenGeek at Jun 13, 2005, 08:05 PM

That could be an option, however, it would be nice to have getBasePath(), getBaseURL(), and getSiteURL() functions in the API for use in snippets and snippet includes, without having to declare it as a global everytime.

Very good suggestion Jason. I think those will come in handy]]>
xwisdom Jun 13, 2005, 10:54 PM https://forums.modx.com/thread/33426/dealing-with-includes#dis-post-183838
<![CDATA[Re: Dealing with includes]]> https://forums.modx.com/thread/33426/dealing-with-includes#dis-post-183837 Quote from: xwisdom at Jun 13, 2005, 07:58 PM

I was more thinking of $base_path

e.g. include $base_path."assets/snippet/mysnippet/myfile.php";


That could be an option, however, it would be nice to have getBasePath(), getBaseURL(), and getSiteURL() functions in the API for use in snippets and snippet includes, without having to declare it as a global everytime.]]>
opengeek Jun 13, 2005, 03:05 PM https://forums.modx.com/thread/33426/dealing-with-includes#dis-post-183837
<![CDATA[Re: Dealing with includes]]> https://forums.modx.com/thread/33426/dealing-with-includes#dis-post-183836
e.g. include $base_path."assets/snippet/mysnippet/myfile.php";
]]>
xwisdom Jun 13, 2005, 02:58 PM https://forums.modx.com/thread/33426/dealing-with-includes#dis-post-183836
<![CDATA[Re: Dealing with includes]]> https://forums.modx.com/thread/33426/dealing-with-includes#dis-post-183835 Quote from: xwisdom at Jun 13, 2005, 07:33 PM

I think it’s best to use absolute paths. I’ve seen this error with php5 and some open_base_dir php setting.

That’s really not an option for me in my development cycle, as I need portable packages that can be easily deployed locally or on various remote servers (LAMP of course). And, I actually solved it by prefixing the file with dirname(__FILE__) like such...

include(dirname(__FILE__).'/somefile.inc.php');
]]>
opengeek Jun 13, 2005, 02:43 PM https://forums.modx.com/thread/33426/dealing-with-includes#dis-post-183835
<![CDATA[Re: Dealing with includes]]> https://forums.modx.com/thread/33426/dealing-with-includes#dis-post-183834 xwisdom Jun 13, 2005, 02:33 PM https://forums.modx.com/thread/33426/dealing-with-includes#dis-post-183834 <![CDATA[Dealing with includes]]> https://forums.modx.com/thread/33426/dealing-with-includes#dis-post-183833
<?php
include "config.inc.php";
if (!class_exists("Database")) { include "db.class.inc.php"; }
...


I moved the code from a PHP 4 to a PHP 5 deployment, and now, although this file gets included fine from the snippet itself, the includes inside the class file are looking elsewhere for the files? Why is this and what’s the best way to handle this so it works in both situations...???]]>
opengeek Jun 13, 2005, 12:30 PM https://forums.modx.com/thread/33426/dealing-with-includes#dis-post-183833