RedirectIntermap-Talk

Summary: Talk page for RedirectIntermap.
Maintainer: Petko (original author: EemeliAro)
Users: (View? / Edit)

This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.

Thanks for reviving this recipe, Petko. With the config settings set to 1, the recipe mostly works for me. But I don't get redirection when using a page text variable within the markup: (:redirect {{$:MyPTV}$PageUrl} quiet=1:)

-- RandyB September 15, 2019, at 09:25 PM

It works for me, what is the content of {$:MyPTV}, do you mean {*$:MyPTV}, is the redirect directive in the page or in a header/footer/included page? Does it redirect somewhere else? Does it stay in the page and display something (what)? Place near the directive {$:MyPTV} and {{$:MyPTV}$PageUrl} and see what they show. From your code I assumed {$:MyPTV} holds a page name like Main.HomePage; if it holds a full URL use just {$:MyPTV} without $PageUrl. BTW, when you redirect to a URL rather than to a page, quiet=1 is unnecessary. --Petko September 16, 2019, at 05:50 AM

Here are my latest three tests and the results I get:

(:MyPTV: {(substr (substr {$?MyPTV} 7 99) 0 -4)}:)
MyPTV={$:MyPTV} 
test={$?test} 
Help.10000 contains (:redirect Help.Help quiet=1:).
In config.php:
 $EnableRedirectQuiet = 1;
 $EnableRedirectIntermap = 1;
 $EnableRedirectExternal = 1;

My test links:
[[{$FullName}?MyPTV=ignore-10000-xxx?test=1|Test 1]]
[[{$FullName}?MyPTV=ignore-10000-xxx?test=2|Test 2]]
[[{$FullName}?MyPTV=ignore-10000-xxx?test=3|Test 3]]

(:if request test 1:)
(:redirect {Help.{$:MyPTV}$PageUrl}:)
(:elseif request test 2:)
(:redirect {Help.10000$PageUrl} :)
(:elseif request test 3:)
(:redirect Help.10000 quiet=1:)
(:ifend:)

My test results:

1. When I click on Test 1, I see "MyPTV=10000 test=1" and the markup (:redirect {Help.10000$PageUrl}:) on the test page; no redirection occurs.

2. When I click on Test 2, the page redirects to Help.10000, at the top I see "(redirected from Main.WikiSandbox)" and below that I see the markup to redirect to Help.Help. So the first redirection occurs, but not the second.

3. When I click on Test 3, I end up on Help.Help. (Which is correct, since I redirect to Help.10000 which further redirects to Help.Help.) But I see "(redirected from Help.10000)" at the top even though Help.10000's markup includes "quiet=1".

-- RandyB September 16, 2019, at 10:20 PM

The order of processing the above markup rules is: first {$?MyPTV} then {Help.10000$PageUrl} and {$:MyPTV}, then {(substr ...)}, then (:if...:) and finally (:redirect...:). Your markup expression outputs something that you want to later evaluate as a page text variable, and the result of it as a page variable, but that never happens. You could link directly to the page you need, without a redirect, or write PHP functions to either have a PageVariable with the result of the text manipulation, or even redirect directly (from PHP) to the requested page. Something like this in config.php:
  $RequestMyPTV = substr(stripmagic(@$_REQUEST['MyPTV']), 7, -4);
  $RequestMyPTVPageUrl = PageVar("Help.$RequestMyPTV", '$PageUrl');
  $FmtPV['$ReqMyPTVPageUrl'] = '$GLOBALS["RequestMyPTVPageUrl"]';

Then in the wiki page, in the first conditional (:redirect {$ReqMyPTVPageUrl}:) About the second "quiet=1" redirection, the recipe has implemented this it differently from the core solution, you may be able to use quiet=1 status=301 to make it work. --Petko September 18, 2019, at 01:41 PM

Thanks for the suggestions and your clear explanation of what went wrong.

And yes, putting in "status=301" did eliminate the "redirected from" message. -- RandyB September 18, 2019, at 05:09 PM

Talk page for the RedirectIntermap recipe (users?).