2.3.6.3. Build URLs to files in the Phorum tree

If you have some non-script files in your module that you need to access through a URL, then make sure that you are generating absolute URLs for these. You can make use of the Phorum setting variable $PHORUM['http_path'] to build these. This setting relates to the "HTTP Path" option under "General Settings" in the admin interface.

Let's asume you have a file named foobar.gif in your "foo" module tree, then you could generate the URL for that file like this:

Example 2.9.  Generating an absolute URL for a file in a module directory

// Since the code probably runs inside a function scope,
// the global $PHORUM variable needs to be imported.
global $PHORUM;

// Build the URL for the foobar.gif.
$url = $PHORUM['http_path'] . "/mods/foo/foobar.gif";

// After this, you could store the URL in the template data, so you
// can use it from the templates. Here an example for filling the
// template variable {MOD_FOO->IMAGE_URL}:
$PHORUM["DATA"]["MOD_FOO"]["IMAGE_URL"] = $url;