Last modified: 2007-03-24 17:44:14 UTC
It would be interessting to have the possibility to enter a "custom format". Something like <ask format="custom" myformat="$0 ($1) [[$2]]">...</ask>. It would give more flexibility to the extension :) E. P.S. I'm on it. I would send a patch when functionnal
Created attachment 3151 [details] The patch to include this feature To test it make a ask this form: <ask format="custom" myformat="%0 (%1)">...</ask> where %0, %1, ..., %X are the "fields" where to put values
I changed things: The custom format is in fact used to generate a "complex search link": I've got a list of year and a list of university. Each student is classified in a year and in a university. I would like, on each year page, a list of search link that can make a cross search. Search queries would be in form like: "[[User:+]] [[Year::Year:MYYEAR]] [[University::University:MYUNIVERSITY]]" The major problem was to generate all of this links... That's why I used this new custom Query Printer... Now the syntax is: <ask format="custom" myformat="THE QUERY TEMPLATE" mylabel="The label produced">QUERY THAT GENERATE LINKS</ask> Exemple, in the year template (which its name is passed as argument 1): <ask format="custom" myformat="[[User:+]] [[Year::Year:{{{1}}}]] [[University::University:%0]]" mylabel="Search students in {{{1}}} in university %0">[[University:+]]</ask> would produce: In the D1 year, if it exists 3 universities: * [[User:+]] [[Year::Year:D1]] [[University::University:University1]] * [[User:+]] [[Year::Year:D1]] [[University::University:University2]] * [[User:+]] [[Year::Year:D1]] [[University::University:University3]] What's the main feature ? If you later add a new university in the "University:" namespace, all years would have a 4th link to make cross search. Technically , I had to change the parser because the template arguments "{{{1}}}" were not replaced in the <ask ...> hook. Then, I unstriped on each call of template. I think it's quite functionnal. Please review my code... It improves SMW and make it capable to create easily database with no configuration ...
Created attachment 3160 [details] The new version (0.2) of this patch wich generates automatically query links The patch to activate it on SMW. See #8828 on how to hack MediaWiki to activate parameters passed to hooks
This has now been implemented in the new format="template" which is very similar to what was suggested above. It takes one parameter template="ArticleName" that allows you to provide a template. This template gets the query outputs for each result "row" as numbered parameters and can format them in any way (including advanced ways based on the parser-hook extension).