Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

Link titles

Summary: Add "title" attributes to all links
Version:2006-03-25
Prerequisites:
Status: Last tested in March-April 2006
Maintainer: Petko
Categories: Markup, Usability, Links

Questions answered by this recipe

How to add "title" attributes to all links?

Note that you can already have link titles for external links, which may be all you need!

[[http://www.wikipedia.org/"The free encyclopedia"|Wikipedia]] will print Wikipedia and a tooltip "The free encyclopedia".

To enable this, you may need to set in your config.php this line:

 $UrlLinkFmt = "<a class='urllink' href='\$LinkUrl' rel='nofollow' title='\$LinkAlt'>\$LinkText</a>";

If you wish to have link titles even for internal links, read on.

Description

Attach:linktitles.phpΔ

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 (*).

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

 include_once('cookbook/linktitles.php');

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

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

  • [[Main/HomePage|Home (Go to the site home)]] prints "Home" (and title "Go to the site home")
  • [[ My website (Blog and freeware stuff) -> http://5ko.free.fr ]] prints "My website" (and title "Blog and freeware stuff")

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

  • [[Welcome -> Home Page]] prints "Welcome" and title "Main.HomePage"
  • [[http://5ko.free.fr/ | My homepage]] titles "http://5ko.free.fr/"

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

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".

Notes

  • This script overwrites the $LinkFunctions array, so if you have defined customized link functions, you may need to do some changes.
  • Note that I wrote this recipe before knowing the tip for the external links tooltips; soon after this I learned about the $UrlLinkFmt/$LinkAlt thing and never again used my recipe. I cannot guarantee that in newer PmWiki versions it will work as it did in March 2006. --Petko

Release Notes

  • 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".

Comments

See Also

Contributors

  • Petko, slightly modified two functions written by Pm (from pmwiki.php)
Edit - History - Print - Recent Changes - Search
Page last modified on January 08, 2008, at 06:27 AM