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.
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 '
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.
$virtualPath = keepurl::make_path();
$virtualURL = make_url($virtualPath);
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:
$url = make_url(keepurl::make_path('./contact/'));
echo '<li><a href="'.$url.'">Contact</a></li>';
||Returns the virtual path, including shortcuts.|
||Returns the nearest section, retraced backwards through any shortcuts.|
||Call a template on an object through a virtual path.|
(string) make_path( $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.
(string) currentsection( $path = '.' )
Returns the nearest section, retraced backwards through any shortcuts.
(mixed) get( $path, $template, $args = '' )
Call a template on an object through a virtual path.