Phorum uses the function phorum_get_url()
to
consistenly build URLs that point to Phorum PHP scripts. It is
recommended that you use this function as well when creating
URLs to scripts yourself, so special features and future changes
will automatically be incorporated in the links you use.
Here is an example of building an URL, which will open the profile page for the user with user_id = 17:
Example 2.7. Generating a profile URL using phorum_get_url()
$url = phorum_get_url(PHORUM_PROFILE_URL, 17);
The argument list that this function takes, depends on the first
argument which tells Phorum what URL type has to be built.
When building other URLs, other arguments will be used.
About all URL types that phorum_get_url()
supports are used for building URLs that point to the scripts
that are bundled with Phorum. Sometimes, you might want to add
an extra script of your own to the Phorum tree (see
Section 2.2.3, “Add-ons”). For those, you can use
phorum_get_url()
as well. The way to go is
simple. You need to use PHORUM_CUSTOM_URL
as
the first argument and add the following parameters to it:
Here is an example of building a URL which links to the
add-on file myfile.php
in the Phorum
installation directory. Lets asume that the URL has to have the
forum_id in it and that it needs to contain the additional
parameters foo=bar
and
baz=foo
:
Example 2.8. Generating a custom script URL using phorum_get_url()
// Build the URL for the add-on script. $url = phorum_get_url(PHORUM_CUSTOM_URL, "myfile", 1, "foo=bar", "baz=foo"); // After this, you could store the URL in the template data, so you // can use it from the templates to link to the add-on script. // Here an example for filling the template variable {URL->MYFILE}: $PHORUM["DATA"]["URL"]["MYFILE"] = $url;