Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

LinkTitles

Summary: Add "title" attributes to all links
Version:20101221
Prerequisites: PmWiki 2.2.22 or newer, or svn revision 2613 or newer
Status: Beta
Maintainer: Petko

This recipe allows you to add link titles to external and internal links.

Note that with PmWiki version 2.2.35 and newer you can already have link titles for all links.

[[Main/Home"Start page"]] will print Home with a tooltip title "Start page".
[[http://www.wikipedia.org/"The free encyclopedia"|Wikipedia]] will print Wikipedia and a tooltip "The free encyclopedia" with a tooltip "The free encyclopedia".
Changelog:
  • tooltips for internal links: enabled since version 2.2.35 and newer
  • tooltips for external links: enabled since version 2.2.14 and newer; in older versions, you can enable it by adding to config.php such a line:
    $UrlLinkFmt = "<a class='urllink' href='\$LinkUrl' rel='nofollow' title='\$LinkAlt'>\$LinkText</a>";

Description

This recipe allows you to add link titles to external and internal links.

Link titles are displayed in a small tooltip when the mouse cursor passes over a link. It can be used to provide additional information and/or URL and is a usability recommended feature.

Installation

To use this script, download itΔ, place it into the cookbook/ folder and add the line

 include_once('cookbook/linktitles2.php');

to a local customization file (local/config.php).

Usage

You can add a link title by placing it in parentheses after the link text:

* [[Main/HomePage|Home (Go to the site home)]]
* [[My website (Freeware stuff) -> http://5ko.free.fr ]]

If you don't have a text in parentheses, the title will be the external URL or the local target page:

* [[Welcome -> Main/Home Page]]
* [[http://5ko.free.fr/ | My homepage]]

To remove a link title, append "()" to the link text, i.e. [[HomePage|Home()]].

* [[Welcome() -> Main/Home Page]]
* [[http://5ko.free.fr/ | My homepage()]]

To keep a parenthesed words in the link text, append "()" or "(some title text)" to the link text, i.e. [[HomePage|Welcome (Homepage)(Test)]] will print "Welcome (Homepage)" and title "Test".

Configuration

LinkTitles 20101221 can be configured. You can add to config.php, before including the recipe, the following commands:

  • $EnableLinkTitleDefaultUrl = 0; to disable a default tooltip for external links (the address) if nothing is provided.
  • $EnableLinkTitleDefaultPage = 0; to disable a default tooltip for internal links (the page name) if nothing is provided.

Advanced admins can change the way a title is defined. For example:

  $LinkTitleRegExp = '/\\|([^\\|]*)\\s*$/';

will allow you to use the markup [[Link|Text|Title]] instead of [[Link|Text(Title)]].

Notes

  • The current version 20101221 is much simpler and more configurable, but requires the latest PmWiki code, version 2.2.22 or newer. For older PmWiki versions, use linktitles.phpΔ instead.
  • Links to anchors in the same page currently do not display a tooltip.

Release Notes

  • 20101221 - remove cloned functions from pmwiki.php, add configuration variables.
  • First release 2006-03-25

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See Also

Contributors

  • Version 20101221 : recipe rewritten by Petko, removed pmwiki.php functions.
  • Version 2006-03-25 : Petko, slightly modified two functions written by Pm (from pmwiki.php).

Comments

See discussion at LinkTitles-Talk?

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on October 28, 2013, at 10:30 PM