How to access the base URL?
|
Aug 14, 2008 21:55
286 posts
|
How can I access the base url for the site from a plugin? right now i'm doing something like: $_SERVER['DOCUMENT_ROOT'] . '/testsite') I think there must be a better way. Thanks |
|
Aug 15, 2008 04:07
37 posts
|
Hi, The framework define a BASE_URL php constant, you can try to use it. |
|
Aug 15, 2008 04:21
286 posts
|
thanks, i'll give it a try! |
|
Aug 15, 2008 06:59
286 posts
|
when i use BASE_URL i get 'URL file access disabled' problem... |
|
Aug 15, 2008 07:08
37 posts
|
What are you trying to do ? |
|
Aug 15, 2008 08:04
286 posts
|
i'm trying to get to a subdirectory in the plugin. i need to require something at myplugin/php/foo.inc and foo.inc needs to go back up and write to something at myplugin/cache |
|
Aug 15, 2008 09:02
37 posts
|
You can try to use relative path or use the FILE constant like:
No ? |
|
Aug 15, 2008 09:59
396 posts
|
@ricks - BASE_URL is not the one you want to use... most hosting systems don't allow url based file access for security purposes. (which is good) Like gido said, just use a relative path, something like one of these:
Otherwise, you can try to use the FROG_ROOT variable as an absolute path, like:
If that fails, do a test with the absolute filename... not nice for production, but try it and see if it works on your system:
|
|
Aug 21, 2008 03:11
286 posts
|
thanks for the suggestions, but do they offer an advantage over $_SERVER['DOCUMENT_ROOT'] ? just wondering. thanks |
|
Aug 21, 2008 07:53
396 posts
|
@ricks - not a huge difference... main thing is, if you use FROG_ROOT or a relative file path, your require_once statement won't break. If you use the SERVER version like in comment #9, you make your plugin dependent on server configuration instead of on Frog configuration. (I.e. Frog might work but your plugin might break) Granted, the possibility of that happening is incredibly small... in other words: you choice. ;-) |