I have seen some news sites that for the print preview
page automatically generate a list of references at the
end of the article. This list is showing all the links
from the page with the corresponding URLs. Here is an
example:
http://trends.newsforge.com/print.pl?sid=04/08/12/162225
You can see a sample of this code at work here:
http://xoops.romanians.bc.ca/modules/news/article.php?storyid=2
Just hit the print button.
A few observations:
- if the URL and the display text are identical
(identity links) then they don't show up in the list
- if the URL and the display text are almost identical
(lookalike links) then again they don't show up,
'almost' means: 'http://' prefix and '/' suffix
- internal links (using the # fragment) are not listed
- for tags the single or double quotes around the
href attribute value are required
This was implemented by adding one method to the
MyTextSanitizer class, it is called extractLinks. In
order to add the list of links to your preview page you
have to call this method and then display the list.
Here is an example for the News module:
$fulltext = $story->hometext . $story->bodytext;
$links = $myts->extractLinks ($fulltext);
if (!empty ($links))
{
echo "
" . htmlspecialchars ($link[1]) .
"
Patch for MyTextSanitizer and sample print page