[ic] Can IC always look in ~/pages/?
Grant
emailgrant at gmail.com
Fri Oct 1 16:45:20 UTC 2010
>>>>>> My suggestion is to use either an actionmap (if "folder-name" is
>>>>>> always
>>>>>> the same) or to use a missing specialsub (if it is not). In either
>>>>>> case, you can strip out the folder name from the beginning of the
>>>>>> path,
>>>>>> grab the page name portion (and if it is blank make it "index"), and
>>>>>> then return the new page name from either the missing specialsub or
>>>>>> the
>>>>>> actionmap for Interchange to process for you.
>>>>>
>>>>> The "folder-name" changes. I do something like the above in an
>>>>> Autoload for GETs, but since all of my POSTs have a path like
>>>>> "/folder-name/process.html",
>>>>
>>>> It should (but don't quote me on this) still work to rewrite the page to
>>>> /process.html, but you need to do it in an actionmap or missing
>>>> specialsub, not from an autoload. Actionmap and missing specialsub have
>>>> the advantage that they fire off before autoload (I think, again don't
>>>> quote me on this) and you can modify the passed path and return it for
>>>> IC to re-parse as the page name. If it sees "process" returned from one
>>>> of these it should treat it as a process page and continue on as
>>>> expected.
>>>>
>>>
>>> No, Autoload comes first. If you are rewriting the URL in Autoload and
>>> intend to
>>> trigger an ActionMap, set $Vend::FinalPath in Autoload, e.g. with the
>>> following tag:
>>>
>>> UserTag mangle_path Order path
>>> UserTag mangle_path Routine<<EOR
>>> sub {
>>> my $path = shift;
>>> $Vend::FinalPath = $path;
>>> }
>>> EOR
>>>
>>> Regards
>>> Racke
>>
>> Thank you Racke and Peter. I'm using [mangle_path] like this in an
>> Autoload:
>>
>> [if scratch folder_name]
>> [tmp path][data session last_url][/tmp]
>> [perl] $Scratch->{path} =~ s/\/$Scratch->{folder_name}//; [/perl]
>> [mangle_path path="[scratch path]"]
>> [/if]
>>
>> I did a lot of testing but I can't figure out how it works. Can
>> anyone tell me how $Vend::FinalPath is used by IC? What does the
>> shift line in the usertag do? I read about shift at perldoc.perl.org
>> but I can't figure out how it is used in mangle_url.tag.
>>
>
> $Vend::FinalPath is used to decide which action (ActionMap) to trigger
> after the Autoload. If you don't change it, it uses the current URL.
I'm actually not using an ActionMap. I'm setting $Vend::FinalPath in
Autoload with [mangle_path] as above and its working well but I've
noticed some inconsistencies so I don't think I understand what it's
really doing. I thought $Vend::FinalPath must determine the path IC
"sees" regardless of the URL, but that logic doesn't seem to hold in
some scenarios.
> shift just grabs the first argument for the function from @_;
I tried to replace:
my $path = shift;
with:
my $path = @_;
but it doesn't work. Does shift do something special here?
- Grant
More information about the interchange-users
mailing list