archive_me1Add my vote for this tag create new tag
, view all tags

Feature Proposal: Backlinks template


There has been some effort to improve the search results from the Backlinks links (see BacklinksSearchDoesNotWork)

But there remains a fundamental problem: the All (backlinks) link does not work as expected. One can either search the current web using %TOPIC%, or other webs using %WEB%.%TOPIC% (with spacedtopic variants): backlinks in the current web cannot be found with the second search! For finding all backlinks we would need 2 searches: first for the current web, then for the other webs.

A backlinks template could do this.


I am not sure if we would need 2 (small) templates to account for both the web search and the all search, or that we could use a url parameter.

-- ArthurClemens - 15 Apr 2005


I have it working just perfectly with the following search strings:


So, using a template to solve the all backlinks is simply not needed. I would be interested in having more template stuff in regular wiki pages. Right now, I am working on some stuff to have the following bullet lists converted automatically into a java script pull down menu (using normal wiki links, macros):

  • MenuItem1
    • SubItem1
    • SubItem1
  • MenuItem2
    • SubItem1

With this, users can customize their site and page navigation much more easily. On top of that, there is more active screen area, without left bar.

-- PeterHuisken - 16 Apr 2005

Peter, I have used these search strings and they do not work. Its not the quality of the expressions, its just that they cannot work.

For instance I am looking for backlinks to WebHome in the Main web. I can't look for the strings "WebHome" or "Web Home" in other webs: they will point to their Web's WebHome. In fact, when a link in another web points to Main.WebHome, it will always have the Web. prefix.

So you have 2 kinds of links pointing to Main.WebHome:

  1. In the Main web: "WebHome", "Main.WebHome" or "[[Web Home]]"
  2. In other webs: "Main.WebHome"

If I want to show all links pointing to Main's WebHome, I can search on "!WebHome" only if I search in the current web. This means a search with web=%WEB% (which is default, so can be omitted, but in any can no web=all).

I have put your search strings in the templates on my test site: http://visiblearea.com/devtwiki/bin/view/Main/WebHome. Check the results of the link "Other webs": you will get a lot of links to WebHomes that are not Main's WebHome.

On the side note: On top of that, there is more active screen area, without left bar.

Be careful not to hide links. Dropdown menus are often not good for navigation, because they require an active decision from the user. And that means he already has to have an idea where to look for. If your users are casual visitors (once a week) or your navigation menu contains different kinds of items that cannot be remembered well (9 or more) you should use a regular (= visible) menu that enhances the user's browsing mode. If you want to save screen estate, you can think about toggling the visibility of the menu. At least the user will know to look into the menu.

Dropdown menus are perfect for "variations of the same kind" things. Like country list, a filter on a search set, or an admin page where you select the client name to fetch different data.

-- ArthurClemens - 16 Apr 2005

To create 2 searches for "All backlinks" I need a new excludeweb parameter, see AddExcludeWebParamToSearch.

-- ArthurClemens - 26 Apr 2005

Update 30 Apr 2005 because of changes to AddExcludeWebParamToSearch

I have something that works.

Searching backlinks in the current web: looks for (example) "WebHome", "Main.WebHome" or "[[Web Home]]", all in the topic's current web
*Backlinks for %URLPARAM{web}%.%URLPARAM{searchtopic}% in %URLPARAM{web}% Web:*

%SEARCH{ search="%URLPARAM{spacedtopic}%([^A-Za-z0-9]|$)|%URLPARAM{web}%.%URLPARAM{searchtopic}%([^A-Za-z0-9]|$)" type="regex" scope="text" excludetopic="%URLPARAM{searchtopic}%" nosearch="on" web="%URLPARAM{web}%" }%

Searching backlinks in all webs: first use the same search as above
*Backlinks for %URLPARAM{web}%.%URLPARAM{searchtopic}% in all Webs:*

%SEARCH{ search="%URLPARAM{spacedtopic}%([^A-Za-z0-9]|$)|%URLPARAM{web}%.%URLPARAM{searchtopic}%([^A-Za-z0-9]|$)" type="regex" scope="text" excludetopic="%URLPARAM{searchtopic}%" nosearch="on" web="%URLPARAM{web}%" }%
Then right beneath search for "Main.WebHome" in all webs except for the current web
%SEARCH{ search="%URLPARAM{web}%.%URLPARAM{spacedtopic}%([^A-Za-z0-9]|$)|%URLPARAM{web}%.%URLPARAM{searchtopic}%([^A-Za-z0-9]|$)" type="regex" scope="text" excludetopic="%URLPARAM{searchtopic}%" nosearch="on" web="all,-%URLPARAM{web}%" }%

This solution uses the exclude web search parameter addition.

The searches are called from the view template:

<a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/TWiki/TWikiSearchBacklinksWeb?searchtopic=%TOPIC%&amp;spacedtopic=%SPACEDTOPIC%&amp;web=%WEB%" title="Find backlinks to this topic in the %WEB% Web" accesskey="w"><span class="twikiAccessKey">W</span>eb</a> %TMPL:P{"sep"}% <a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/TWiki/TWikiSearchBacklinksAll?searchtopic=%TOPIC%&amp;spacedtopic=%SPACEDTOPIC%&amp;web=%WEB%" title="Find backlinks to this topic in all Webs" accesskey="l">Al<span class="twikiAccessKey">l</span> webs</a>

3 parameters are passed: the topic (searchtopic), the spaced topic (spacedtopic) and the web (web).

I have made a test setup with 2 topics (see http://visiblearea.com/devtwiki/bin/view/Main/WebHome and try bottom links - BTW use access keys 'w' and 'l').

But this would be better if implemented in a template (2 templates in fact). But I am not sure how to do this - I assume a new bin/backlinks file would be needed, and something in Search.pm to call the right template, or even a Backlinks.pm?

-- ArthurClemens - 30 Apr 2005


Backlinks templates implemented in DEVELOP SVN 4213 (see also attached files).

The 2 searches in the view template are:

  • Web search: %SCRIPTURLPATH%/backlinks%SCRIPTSUFFIX%/%WEB%/%TOPIC%?action=web
  • All Webs search: %SCRIPTURLPATH%/backlinks%SCRIPTSUFFIX%/%WEB%/%TOPIC%?action=allwebs

-- ArthurClemens - 01 May 2005

There is one bug with this implementation: the %SPACEDTOPIC% that is used in the template returns a url-encoded string: a space becomes %20. When this is passed as query parameter, it works fine because the url-encoded characters are interpreted. But when used in a template, the %20 just stays what it is, and this results in topics not being found.

-- ArthurClemens - 01 May 2005

Arthur, you did not provide the corresponding updates to ClassicSkin. The two "official" skins must be kept consistent.

-- ThomasWeigert - 01 May 2005

And you do not need to include twiki in your template, as this is already included through search.

  • OK. I remember having problems before in search templates without this, but maybe that was something else. -- ArthurClemens - 02 May 2005
    • There were a couple of other templates with the extra include - I have removed the lines. -- ArthurClemens - 02 May 2005

-- ThomasWeigert - 01 May 2005

Still one more annoyance (also in the old backlinks search): topics listed in the left bar are also found. This results in a lot of search results noise. About time we could limit search to the topic text only.

  • This is not true: only the topic is being searched. So no noise. -- ArthurClemens - 04 May 2005

-- ArthurClemens - 03 May 2005

Arthur, you didn't respond to my mail. I am dead set against adding a new script to do this, especially as it duplicates oops and Oops.pm. Unless I hear from you I'm going to revert that change.

-- CrawfordCurrie - 03 May 2005


How to solve this then?

-- ArthurClemens - 03 May 2005

I agree with Crawford. These two scripts backlinks and oops are indeed too close for comfort. The only difference is the template being chosen. But you already pass the action flag to select template in backlinks. Why don't you just pass template directly to oops instead? That would allow you to do without the script. Bad enough that we had to add 3 extra templates per skin...

-- ThomasWeigert - 03 May 2005

Changed to use "oops" and checked in SVN 4248

-- CrawfordCurrie - 03 May 2005

Hm. Shouldn't the Sandbox.TestTopic3 on ntwiki have a backlink to Sandbox.WebHome? See http://develop.twiki.org/~develop/cgi-bin/oops/Sandbox/TestTopic3?template=backlinksweb

This feature is important to work correctly! Something has been messed up lately.

-- FranzJosefSilli - 03 May 2005

This may have to do with the erroneously printed <<" in the left edge (which is from =<body>); there is somewhere a typo that snuck into here, I think....

-- ThomasWeigert - 03 May 2005

I now understand the oops template implementation. Didn't know that was possible.

One part of the query was still missing to find all backlinks: %TOPIC%([^A-Za-z0-9]|$). Perhaps this was too obvious for us to notice before. Now in SVN 4259.

The search on ntwiki now works correctly (surprisingly the all webs search points to TWiki.TWikiTutorial, which is correct too).

-- ArthurClemens - 03 May 2005

Nice one, Arthur! smile Note that the oops templates on DevelopBranch also support the def parameter, allowing you to select and render a single definition out of all the definitions in a single template e.g. ?template=oopsmessages;def=something

-- CrawfordCurrie - 04 May 2005

Still I get the goosebumps every time I see 'oops' appear in the url. Then I see the page title and everything appears to be ok. It is a misfortunate name for a template.

-- ArthurClemens - 04 May 2005

I have added classic skin templates too. SVN 4267 and 4268.

-- ArthurClemens - 04 May 2005

Yeah, oops is a legacy name for the script, I think. 'report' would be a lot more appropriate. Can anyone think of a reason not to change the script name?

-- CrawfordCurrie - 05 May 2005

Arthur, you added search-based backlinks templates again. I thought we were going to use oops templates?

-- ThomasWeigert - 05 May 2005

Where did I add them? On develop.twiki.org I see oops templates.

-- ArthurClemens - 05 May 2005

We now have again a set of backlinks*.*.tmpl files which showed up yesterday.

-- ThomasWeigert - 05 May 2005

Ah! The oops script calls the backlinksxxx templates. Perhaps they should be called oopbacklinks, oopsbacklinksweb and oopsbacklinksallwebs.

-- ArthurClemens - 05 May 2005

Moved analysis/testcases to Bugs:Item1386.

-- DanielKabs - 12 Jan 2006

Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt backlinks.pattern.tmpl.txt r1 manage 0.6 K 2005-05-01 - 20:17 ArthurClemens templates/backlinks.pattern.tmpl - general template
Texttxt backlinksallwebs.pattern.tmpl.txt r1 manage 0.5 K 2005-05-01 - 20:12 ArthurClemens templates/backlinksallwebs.pattern.tmpl - template for search in all webs
Texttxt backlinksweb.pattern.tmpl.txt r2 r1 manage 0.5 K 2005-05-01 - 20:48 ArthurClemens templates/backlinksweb.pattern.tmpl - template for web search
Edit | Attach | Watch | Print version | History: r37 < r36 < r35 < r34 < r33 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r37 - 2006-01-12 - DanielKabs
  • 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.