create new tag
, view all tags

Feature Proposal: Variable to access Render::makeAnchorName


Allows dynamic cross-references to be easily generated.


A new variable %MAKEANCHOR{"text"}% would produce the same HTML anchor that is created for TOCs, etc. by Render::makeAnchorName().

I'm looking for a mechanism to create the anchor name for a heading on-the-fly. For instance, a SEARCH returns a list of interesting headings, and a link could be easily created with


This would simplify things like "Latest News" (grab news headlines from news topics), "Random Tips" (grab a random heading from tips topics), etc.

-- PankajPant - 23 May 2005

Impact and Available Solutions

WhatDoesItAffect: Rendering, Vars, Search


If necessary, user documentation of new features introduced by this proposal.


Example uses of features introduced by proposal.


Any comments on how the feature is implemented or could be improved


Interesting. Can you provide detail on how this would work? Presumably you propose to collapse whitespace etc. If so, it might be an idea to consider an %WIKIFY function, which would convert any text string to a wikiword, and thus be more general-purpose (analagous to %SPACEOUT which inserts spaces in wikiwords)? You could then write

If that doesn't target heading anchors, perhaps we need to reconsider how heading anchors are generated....

-- CrawfordCurrie - 23 May 2005

Reconsidering how heading anchors are generated is a good idea anyway, cause the patch provided in TocUniqueName doesn't work on Develop and there are/have been multitudes of other problems with %TOC% too (see TocHandlingNeedsOverhaul).

-- FranzJosefSilli - 24 May 2005

I don't think %WIKIFY{}% does the same thing as %MAKEANCHOR{}% since the latter removes some cruft from headings (HTML tags, etc.).

My immediate need is as follows. We have a Tips page where each tip is a H3 heading followed by some text. Using the same technique as TWiki's Tip of the Day, I am able to find all tips, pick a random one, and display the heading and the first 80 chars of text (using INCLUDE{pattern\="..."}), but I have no way of linking to the actual place in the Tips topic. That's where %MAKEANCHOR{$tip}% comes in.

In the long term, I also envision a way to make this work with CommentPlugin. The comment template would contain a pulldown menu of the topic's headers, and the comment would go right after the selected heading (preferable highlighted as a recognizable Note or Post-It). All CommentPlugin needs is the anchor, and the proposed variable would provide that.

-- PankajPant - 24 May 2005

OK. I think you should address your immediate need with a plugin. The longer term requirement is interesting and a good idea, but we should do it by restructuring the anchors on headings, and using WIKIFY (though there is still a question about how to make heading targets unique). As Franz says, TOC handling and headings in general need an overhaul. So I'm adding this to the list for EdinburghRelease, in the hope that a code will get interested and pick it up.

-- CrawfordCurrie - 24 May 2005

Back in 2005, I had implemented a plugin to serve my need (didn't publish it since it called a non API function: Render::makeAnchorName).

As the time approaches to upgrade our TWiki, I was wondering whether any recent changes allow me to implement this feature without having to port the plugin (which shouldn't be too hard since this was very straightforward). Ideally, TWikiFns would have been the perfect way to go.

-- PankajPant - 01 Jun 2007

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2007-06-01 - PankajPant
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.