This module can be used to take advantage of a feature of the Shortcut type, called 'keep url'. When enabled you can access objects through a shortcut as if they were a child of the shortcut object. Using this module you can see if an object is accessed through such a shortcut and recreate the path, including this shortcut.

For example, you have two sites, each with a completely different URL. But each site uses a common set of graphics or icons. You can either copy these images, but that means updating two or more sets of graphics every time something changes, or you can create a shortcut in each site to the common graphics folder. The problem is that the URL to such an icon normally would become 'unclean', e.g.

http://www.mysite.com/ariadne/loader.php/sites/common/myicon.png 

instead of

http://www.mysite.com/graphics/common/myicon.png

By creating a shortcut called 'common' in the graphics folder of each site pointing to the shared folder of icons and selecting the 'keep url' option, you can get access using the nicer url. But if you have a template for displaying this image and access $path, it will still say '/sites/common/myicon.png/'.

This is where mod_keepurl comes in. The following code shows how to get the path used to access the current object and how to generate a url based on this path.

<pinp>
load('mod_keepurl.php');
$virtualPath = keepurl::make_path();
$virtualURL = make_url($virtualPath);
...
</pinp>

Now you can re-use the URL the user followed to get to this page. You can also create the correct paths to other pages. Ariadne keeps track of all shortcuts it encounters when following a path. Mod_keepurl uses that information to retrace this path. The following code creates a link to another page, while keeping any shortcuts intact in the path and url:

<pinp>
load('mod_keepurl.php');
$url = make_url(keepurl::make_path('./contact/'));
echo '<li><a href="'.$url.'">Contact</a></li>';
</pinp>

Methods

(string) make_path Returns the virtual path, including shortcuts.
(string) currentsection Returns the nearest section, retraced backwards through any shortcuts.
(mixed) get Call a template on an object through a virtual path.

make_path

(string) make_path( $path = '.' )

(string) $path The real path to an object.

This method returns the virtual path to the given object. This virtual path retraces through any shortcut used in the current http request.

currentsection

(string) currentsection( $path = '.' )

Returns the nearest section, retraced backwards through any shortcuts.

get

(mixed) get( $path, $template, $args = '' )

Call a template on an object through a virtual path.