PathMunging

From iGeek
Assuming I have a {PATH} = /Animals/Pets/Dogs/
And 3 articles under it = Snoopy, Goofy, Toto

{{StrStripLast|{{{Title}}}}} <- this strips [[Atom/Test|Atom/Test]] to [[Atom/Test|Test]]


For the query: {{#ask: [[Category: {PATH} }}
I’m getting back full path names in #ask:  [[{{FULLPAGENAME}}|FULLPAGENAME}}]]

The default result was:
[[/Animals/Pets/Dogs/Snoopy|/Animals/Pets/Dogs/Snoopy]]
[[/Animals/Pets/Dogs/Goofy |/Animals/Pets/Dogs/Goofy]]
[[/Animals/Pets/Dogs/Toto |/Animals/Pets/Dogs/Toto]]

And what I want it in the [[ {{FULLPAGENAME}} | {{SUBPAGENAME}} ]] (comma delimited)— without installing extensions, etc. 

So here’s my hack… er solution. 

This query will get a list of links for all things in the Category {PATH} and pass them to the template Path_Stripper

{{#ask: [[Category: {PATH} ]]
| ?=
| format=plainlist
| template=Path_Stripper
| userparam= {PATH}
| sep=, 
}}

The Template:Path_Stripper strips out the path (after the pipe character, and makes sure to return it) using the following:

{{#replace:{{{1|}}}|{{!}}{{{#userparam}}}|{{!}}}}

The new results were: [[/Animals/Pets/Dogs/Snoopy|Snoopy]], [[/Animals/Pets/Dogs/Goofy |Goofy]], [[/Animals/Pets/Dogs/Toto |Toto]]
Cookies help us deliver our services. By using our services, you agree to our use of cookies.