Allow redirect plugin to use fragment identifiers (section/anchor ids) (patch included)
- Status
- Open
- Subject
- Allow redirect plugin to use fragment identifiers (section/anchor ids) (patch included)
- Version
- 1.9.x
2.x
3.x - Category
- Feature request
- Patch
- Feature
- Wiki Plugin (extends basic syntax)
Search engine optimization (SEO) - Submitted by
- lbmaian
- Lastmod by
- Marc Laporte
- Rating
- Description
- The redirect plugin currently lacks the ability to include fragment identifiers, e.g.
{REDIRECT(page=Foo#some_id)/}does not work; the resulting URL istiki-index.php?page=Foo#some_id&redirectpage=this_pageinstead oftiki-index.php?page=Foo&redirectpage=this_page#some_id. - Solution
This patch provides a new parameter called "section" which can be set to the anchor id (not including the "#"). I decided to add this new parameter instead of better parsing of the "page" parameter to be consistent with the fragment syntax for internal links (
((Foo|#bar))- note how it's not((Foo#bar)))--- wikiplugin_redirect.php.old 2009-04-29 07:02:08.000000000 -0500 +++ wikiplugin_redirect.php 2009-05-20 12:22:21.028250000 -0500 @@ -6,7 +6,7 @@ // @author damian aka damosoft 30 March 2004 function wikiplugin_redirect_help() { - return tra("Redirects you to another wiki page").":<br />{REDIRECT(page=pagename [,url=http://foobar])/}"; + return tra("Redirects you to another wiki page").":<br />{REDIRECT(page=pagename [,section=section_id] [,url=http://foobar])/}"; } function wikiplugin_redirect_info() { @@ -22,6 +22,11 @@ 'name' => tra('Page Name'), 'description' => tra('Wiki page name to redirect to.'), ), + 'section' => array( + 'required' => false, + 'name' => tra('Section/anchor id'), + 'description' => tra('Id of section/anchor within wiki page to redirect to (see id attribute of <a> elements in HTML source of wiki page).'), + ), 'url' => array( 'required' => false, 'name' => tra('ur l'), @@ -43,11 +48,15 @@ } else { /* SEO: Redirect with HTTP status 301 - Moved Permanently than default 302 - Found */ if (isset($page)) { - header("Location: tiki-index.php?page=$page&redirectpage=".$_REQUEST['page'], true, 301); + if (isset($section)) + $section = '#'.$section; + else + $section = ''; + header('Location: tiki-index.php?page='.urlencode($page).'&redirectpage='.$_REQUEST['page'].$section, true, 301); exit; } if (isset($ur l)) { - header("Location: $ur l"); + header("Location: $ur l", true, 301); exit; } } - Priority
- 25
- Demonstrate Bug on Tiki 19+
-
This bug has been demonstrated on show2.tiki.org
Please demonstrate your bug on show2.tiki.org
Show.tiki.org is not configured properlyThe public/private keys configured to connect to show2.tiki.org were not accepted. Please make sure you are using RSA keys. Thanks.
- Demonstrate Bug (older Tiki versions)
-
This bug has been demonstrated on show.tikiwiki.org
Please demonstrate your bug on show.tikiwiki.org
Show.tiki.org is not configured properlyThe public/private keys configured to connect to show.tikiwiki.org were not accepted. Please make sure you are using RSA keys. Thanks.
- Ticket ID
- 2516
- Created
- Wednesday 20 May, 2009 17:34:34 UTC
by Unknown - LastModif
- Sunday 07 June, 2009 16:15:30 UTC