Description
The uLink module provides universal filtering {1} which allows you to define tags like [l|link_to_node|text_to_appear|attributes] and replace them with appropriate html code {2}, user defined text or code, or third party rendered code or text {3} to provide links, display images, fill with text or all.
This module defines the protocol and giving the framework to generate the outputs, which can be configured or extended through the settings page {4} and by implementing the hooks [1]. Hence, More than one module may be generating the output, in case, they can optionally be enabled, cascaded or added {5}.
The module comes with basic, but powerful default implementation {6} and two other supporting modules ulink_gallery [2]- which provides image gallery like feature and ulink_imagecache [3]- which provides imagecache integration. They also give a good demonstration on how uLink could be extended to match different filtering needs.
Detailed Description
- Universal filtering
The main objective of the module is to provide universal filtering which is independent of the objectives of the user i.e. expected output text or code, limitations and expectations of the site administrator and target (of the link) type. However filtering is dependent on the tag ie [l|link_to_node|text_to_appear|attributes] though.Through the powerful and complex settings {4} available in the under administrative settings rendering can be configured individually for different target types {7}. Alternatively, specific rendering can be given by implementing hooks. Please refer to the developer documentation for details. - HTML code
[l|link_to_node|text_to_appear|attributes] will be replaced by module implementation’s output. This eliminates the need to type html tags and allows uniform way of entering links.
- Third party rendered code
uLink module provides the skeleton for other modules to implement and extend the functions. Other modules can implement the hooks [1] and provide different outputs. ulink_gallery and ulink_imagecache are two perfect examples.
- Settings page
Available under : admin > Settings > ulink > (admin/settings/ulink/files)
Settings page allows user to choose the modules implementing hooks ie enable them and modify the order of cascading the output {5} individually for all the types {7} supported. Through these setting pages, other modules implementing the modules will display module specific settings. For example ulink_gallery provides settings related to its implementation in this page.
- Multiple implementations There may be more than one module implementing the hook for a particular type. For example, with the default distribution users have ulink and ulink_gallery providing rendering for files type. In the settings page there are three options (Disabled, Cascade the module’s rendering to the output, Cascade only if the previous output is empty) and weight.
- Disabled: Not to use this modules rendering
- Cascade the module’s rendering to the output: Cascade the outputs in the order given by the weight. For example if both ulink and ulink_gallery are selected with this option where ulink is with weight = -2 and ulink_gallery is with weight = 3, output will be of ulink’s output followed by ulink_gallery’s output.
- Cascade only if the previous output is empty: This output will be used only when all other modules with higher priority as determined by the weight options return null.
For example, if ulink (weight = -2) is selected with option2 and ulink_gallery (weight = 3) is selected with option3 ulink_gallery’s output will be selected only if ulink’s output is null. As explained above, multiple renderings can be enabled, cascaded and optionally added.
- Default implementation
Although this module is meant to provide only the framework for universal filtering, it provides a powerful default implementation as follows. Except for image type, it gives three different type of rendering.- Hardcoded – user can’t modify the html output, however he can choose what should come for the text when user fails to enter anything for text (eg [l|node/2]) through configure – option.
- Macro substitution (Tokens) – When token module is available uLink is making use of it, by allowing users to use tokens for the following. Here user can use tokens to insert additional information like node-title, user-name. Detailed help on token is available in settings page.
- Use this when text is empty: the text part to be added when user fails to enter anything for text.
- Token tag to be rendered: The output; together with tokens and html code user have the full control over the output.
- Token tag to be rendered if the object is not available:
The output when the target is local (node, user, comment, local file or local image) and it does not exist ie broken link; together with tokens and html code user have full control over the output.
- PHP code – user has the fullest control over the output. Detailed help on php variables is available in settings page. User returns the output using return tag.
Eg: return l($text.” ( “.$object->subject.” )”, $path, $link["attributes"]);
- Types supported
The following target types are supported: node, user, comments, images (local), files (local), images (external) and files(images).
- For image type user can choose the following outputs: Only image, Only link, Image and link
- In addition, users can use macros to avoid typing similar attributes repeatedly.
- Macros can be added under general settings
Admin > Settings > ulink > General settings (admin/settings/ulink)
Here macros are entered in the following format ( “name_of_macroA” => “attribute1=value,attribute2=value”, ”name_of_macroB” => “attribute3=value,attribute4=value”,..)
For example, (”imagelist”=>”class=imagelist”, “photos”=>”width=200,height=100″ ) - Then in the tag it can be called easily by specifying the macro name in the following format
[l-name_of_macro1|link_to_node|text_to_appear|attributes]
For example, [l-photos|files/image.png|my wedding photo] which is equivalent to [l|files/image.png|my wedding photo|width=200,height=100]
External References
- Implementing uLink hooks
- Readme of ulink_gallery module
- Readme of ulink_imagecache module
Usage
- [l|link] or
- [l|link|text] or
- [l|link|text|attributes] or
- [l|link||attributes] or
- [l-macro|link|text] or
- [l-macro|link] or
Link can be specified in three ways
- External links – by using complete absolute url
eg: http://www.drupal.org/project/ulink - Internal drupal supported links or files – by using drupal recognizable url
eg: node/12, node/3#comment-1, user/2, files/drupal.png - Internal non drupal links – by starting the “/”
eg: /files/drupal.png, /sites/default/temp.txt - If internal drupal link is specified and, link is not found under default implementation tags specified broken links will be rendered.
Text can be anything user wanted to display in the link, however for images by default this will be used for title
Attributes are additional parameters to modify the rendering, for example, image type can be given class=image or width=120. eg: [l|/files/myphoto.jpg|my photo|width=200,height=300]
It can also contain information to rendering modules
- forcelink=true, is used to link the image instead of displaying it.
- filter=images, is used to set filter in ulink_gallery
- filter=image_extension_in_regular_expressions, is used to add parse extensions in ulink_gallery
- preset=preset-name, is used to get imagecache preset in ulink_imagecache

