Hello Bradley, On Tuesday, July 10, 2007, 2:35:07 PM, you wrote:
BH> I have an article with multiple instances of the same relationship: BH> -----------------------Banggai BH> Cardinalfish---------------------------- BH> [[native range::Banggai Islands]] BH> [[native range::Indonesia]] BH> [[native range::Sulawesi]] BH> [[common name:={{PAGENAME}}]] BH> [[Category:Species]] BH> --------------------------------------------------------------------------------- BH> I am using the Semantic Forms extension to collect this data BH> through a template. The code above is a simplified representation BH> cutting out other data that's not relative to my question. I would BH> like to list the "native range" relationships for this page BH> separated by commas but have control over the output of each BH> native range so that I can provide links and/or other data BH> specific to that native range. Most likely I will want to BH> suppress the output of the native range above once I have the BH> comma separated list but that should simply be a matter of using BH> CSS to set the display to none. The real problem is creating the BH> comma separated list. This was my first attempt: BH> --------------------------------------------------------------------------------- BH> <ask format="template" template="Native range display"> BH> [[Category:Species]] BH> [[common name:=Banggai Cardinalfish]] BH> [[native range::*]] BH> </ask> BH> --------------------------------------------------------------------------------- BH> ------------------Template:Native range display-------------------- BH> '''Native range(s):''' {{{2}}} BH> --------------------------------------------------------------------------------- BH> The problem with the above "ask" is that Semantic MediaWiki BH> is returning the comma separated list for me in one row. I want it BH> to return a separate row for each "native range" so that I can BH> control the output of each one. If I put the relationship in the BH> native range articles instead of the species articles I could BH> easily create an "ask" query that would return separate rows. BH> However, this would be counter-intuitive for users entering data BH> and isn't really an option. BH> Does anyone have any suggestions on how I could write a query BH> that would give me separate rows for each instance of a BH> relationship (or attribute) within an article? BH> Thanks, BH> Bradley At present, there is nothing you can do to sepate the "native range" values because SMW forms the comma separated list before passing it to the Template. What we really need is the ability to have multiple templates being used. That way the template= parameter would give a list of templates. The first template would be used as now, and the second and subsequent templates would be used to format the values from each column. So: -----Some Page----- [[reference A::page X]] [[reference A::page Y]] [[attribute B:=value P]] [[attribute B:=value Q]] -----Other page---- <!-- NB no template given for column 1 --> <ask format=template template="main template;;col 2 template;col 3 template"> [[reference A::+]][[reference A::*]] [[attribute B:=+]][[attribute B:=*]] </ask> ----main template---- |- | {{{1}}} | {{{2}}} | {{{3}}} ----col 2 template---- {{#if:{{{1|}}}|<nowiki/> * [[{{{1}}}]]}}{{#if:{{{2|}}}|<nowiki/> * [[{{{2}}}]]}}{{#if:{{{3|}}}|<nowiki/> * [[{{{3}}}]]}}{{#if:{{{4|}}}|<nowiki/> * [[{{{4}}}]]}}{{#if:{{{5|}}}|<nowiki/> * [[{{{5}}}]]}} ----col 3 template---- {{#if:{{{1|}}}|<nowiki/> * {{{1}}}}}{{#if:{{{2|}}}|<nowiki/> * {{{2}}}}}{{#if:{{{3|}}}|<nowiki/> * {{{3}}}}}{{#if:{{{4|}}}|<nowiki/> * {{{4}}}}}{{#if:{{{5|}}}|<nowiki/> * {{{5}}}}} The above would produce tabular layout with the items in the 2nd and 3rd columns being bulleted lists rather than comma separated. Lets hope something like this arrives in the next version of SMW. On a similar note it might be useful if we had headertemplate= and footertemplate= parameters for ask, which are only used when there is something to display. -- Best regards, Peter ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Semediawiki-user mailing list Semediawiki-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/semediawiki-user