From: Max-Leonhard v. S. <mlv...@ya...> - 2012-11-05 12:33:16
|
Hello everyone, I have basically the same question as already asked by Martinwiss on this help page: http://semantic-mediawiki.org/wiki/Help_talk:Displaying_information#x.22JOIN.22-ing_information_from_multiple_categories_.3F.3F.3F_128 In the responses, it is mentioned to use a template with a #show function. However I am not really clear what is meant. Can someone send me more details? Thanks a lot, cheers! Max Here is the original question from Martinwiss: How is it possible to join information from several pages in an inline query? Her is an example: Events takes place in locations. I have to categories: Events and Locations, in order to prevent data redundancy. Every event is a page with information about the event, and every location is a page with information about the location as well as it's coordinates. How can I make an inline query that lists events as well as the coordinates where they take place, although the information about the corrdinates is not shown on the event page (where you can only find information about the location-page of the event). {{#ask: [[Category:Events]] |?Has starttime |?Has endtime |?Has location <--- of type page |?Har more information... |format=filtered }} is it possible to combine with this... {{#ask: [[Category:Locations]] |?Has adress |?Has contact person |?Has coordinates |?Has moore information |format=datatable }} In SQL you would normally do this with a JOIN is there an equivalent way to join information in SMW? into something like this... {{#ask: [[Category:Events]] JOIN [[Category:Locations]] ...ON Event.Location = Location |?Event.Has starttime |?Event.Has endtime |?Location.Has coordinates |format=filtered }} I am sure that wont work, but I hope you understand what I want to achieve. Take care! Martin |
From: doug b. <c.d...@gm...> - 2012-11-12 16:08:48
|
The trick is to pass the results of the first #ask query (the Events one, in the example) to a template which then uses additional #ask or #show calls on the appropriate column(s) to fetch the next level of information (Location). For example, create a template called "Event row" <includeonly> | {{{?Has starttime|}}} | {{{?Has endtime|}}} | {{#show: {{{?Has location|}}} | ?Has coordinates }} | {{{?Has more information|}}} |- </includeonly> Note that the surrounding <includeonly> tags are supposed to be important, so don't forget them. Now, on the original #ask query, do something like this: {{#ask: [[Category:Events]] |?Has starttime |?Has endtime |?Has location |?Has more information |format=template |template=Event row |introtemplate= <---Name of template that contains only opening tag of wikitable and header rows, e.g. {| !Start time !! End time |- |outrotemplate= <-- Name of template that contains only closing tag of wikitable, e.g |} |link=none <-- so that surrounding [[]] don't mess up the template |headers=hide |limit=1000 }} If you want links on the resulting table, you have to add them manually into columns in the template, e.g. [[{{{?Has more information|}}}]] More info here: http://semantic-mediawiki.org/wiki/Help:Result_formats and here: http://semantic-mediawiki.org/wiki/Help:Template_format Hope this helps! doug On Mon, Nov 5, 2012 at 7:33 AM, Max-Leonhard von Schaper < mlv...@ya...> wrote: > Hello everyone, > > I have basically the same question as already asked by Martinwiss on this > help page: > > http://semantic-mediawiki.org/wiki/Help_talk:Displaying_information#x.22JOIN.22-ing_information_from_multiple_categories_.3F.3F.3F_128 > > > In the responses, it is mentioned to use a template with a #show function. > > > However I am not really clear what is meant. Can someone send me more > details? > > Thanks a lot, cheers! > Max > > Here is the original question from Martinwiss: > How is it possible to join information from several pages in an inline > query? > Her is an example: Events takes place in locations. I have to categories: > Events and Locations, in order to prevent data redundancy. Every event is a > page with information about the event, and every location is a page with > information about the location as well as it's coordinates. How can I make > an inline query that lists events as well as the coordinates where they > take place, although the information about the corrdinates is not shown on > the event page (where you can only find information about the location-page > of the event). > {{#ask: [[Category:Events]] |?Has starttime |?Has endtime |?Has location > <--- of type page |?Har more information... |format=filtered }} > is it possible to combine with this... > {{#ask: [[Category:Locations]] |?Has adress |?Has contact person |?Has > coordinates |?Has moore information |format=datatable }} > In SQL you would normally do this with a JOIN is there an equivalent way > to join information in SMW? into something like this... > {{#ask: [[Category:Events]] JOIN [[Category:Locations]] ...ON > Event.Location = Location |?Event.Has starttime |?Event.Has endtime > |?Location.Has coordinates |format=filtered }} > I am sure that wont work, but I hope you understand what I want to achieve. > Take care! Martin > > ------------------------------------------------------------------------------ > LogMeIn Central: Instant, anywhere, Remote PC access and management. > Stay in control, update software, and manage PCs from one command center > Diagnose problems and improve visibility into emerging IT issues > Automate, monitor and manage. Do more in less time with Central > http://p.sf.net/sfu/logmein12331_d2d > _______________________________________________ > Semediawiki-user mailing list > Sem...@li... > https://lists.sourceforge.net/lists/listinfo/semediawiki-user > |
From: Max-Leonhard v. S. <mlv...@ya...> - 2012-11-13 11:05:32
|
Hello doug, thanks, yes that is very good explained. Thanks! ________________________________ Von: doug b. <c.d...@gm...> An: Max-Leonhard von Schaper <mlv...@ya...> CC: "sem...@li..." <sem...@li...> Gesendet: 0:08 Dienstag, 13.November 2012 Betreff: Re: [Semediawiki-user] JOIN between two category asks The trick is to pass the results of the first #ask query (the Events one, in the example) to a template which then uses additional #ask or #show calls on the appropriate column(s) to fetch the next level of information (Location). For example, create a template called "Event row" <includeonly> | {{{?Has starttime|}}} | {{{?Has endtime|}}} | {{#show: {{{?Has location|}}} | ?Has coordinates }} | {{{?Has more information|}}} |- </includeonly> Note that the surrounding <includeonly> tags are supposed to be important, so don't forget them. Now, on the original #ask query, do something like this: {{#ask: [[Category:Events]] |?Has starttime |?Has endtime |?Has location |?Has more information |format=template |template=Event row |introtemplate= <---Name of template that contains only opening tag of wikitable and header rows, e.g. {| !Start time !! End time |- |outrotemplate= <-- Name of template that contains only closing tag of wikitable, e.g |} |link=none <-- so that surrounding [[]] don't mess up the template |headers=hide |limit=1000 }} If you want links on the resulting table, you have to add them manually into columns in the template, e.g. [[{{{?Has more information|}}}]] More info here: http://semantic-mediawiki.org/wiki/Help:Result_formats and here: http://semantic-mediawiki.org/wiki/Help:Template_format Hope this helps! doug On Mon, Nov 5, 2012 at 7:33 AM, Max-Leonhard von Schaper <mlv...@ya...> wrote: Hello everyone, > >I have basically the same question as already asked by Martinwiss on this help page: >http://semantic-mediawiki.org/wiki/Help_talk:Displaying_information#x.22JOIN.22-ing_information_from_multiple_categories_.3F.3F.3F_128 > > >In the responses, it is mentioned to use a template with a #show function. > > >However I am not really clear what is meant. Can someone send me more details? > >Thanks a lot, cheers! >Max > >Here is the original question from Martinwiss: >How is it possible to join information from several pages in an inline query? >Her is an example: Events takes place in locations. I have to categories: Events and Locations, in order to prevent data redundancy. Every event is a page with information about the event, and every location is a page with information about the location as well as it's coordinates. How can I make an inline query that lists events as well as the coordinates where they take place, although the information about the corrdinates is not shown on the event page (where you can only find information about the location-page of the event). >{{#ask: [[Category:Events]] |?Has starttime |?Has endtime |?Has location <--- of type page |?Har more information... |format=filtered }} >is it possible to combine with this... >{{#ask: [[Category:Locations]] |?Has adress |?Has contact person |?Has coordinates |?Has moore information |format=datatable }} >In SQL you would normally do this with a JOIN is there an equivalent way to join information in SMW? into something like this... >{{#ask: [[Category:Events]] JOIN [[Category:Locations]] ...ON Event.Location = Location |?Event.Has starttime |?Event.Has endtime |?Location.Has coordinates |format=filtered }} >I am sure that wont work, but I hope you understand what I want to achieve. >Take care! Martin >------------------------------------------------------------------------------ >LogMeIn Central: Instant, anywhere, Remote PC access and management. >Stay in control, update software, and manage PCs from one command center >Diagnose problems and improve visibility into emerging IT issues >Automate, monitor and manage. Do more in less time with Central >http://p.sf.net/sfu/logmein12331_d2d >_______________________________________________ >Semediawiki-user mailing list >Sem...@li... >https://lists.sourceforge.net/lists/listinfo/semediawiki-user > |