Hi David, You shouldn't be storing inverse relationships (like "ComposedOf") at all - rather, that information should get directly queried whenever you want to display it. And the variable to use, when you want to display a page's name, is {{PAGENAME}} - so, in the template, you could add a query like:
{{#cargo_query:table=Place|fields=_pageName|where=PartOf = '{{PAGENAME}}'}} -Yaron On Fri, Sep 3, 2021 at 8:03 PM David Epstein <david...@umich.edu> wrote: > Sam and Yaron, > > > I'm trying to implement the inverse of PartOf (ComposedOf) as discussed on > this list a few days ago (also at end of this email). I'm using Cargo, > PageSchemas, and PageForms. My understanding is that ComposedOf would not > be part of the schema, but would be a manual edit to the automatically > generated template for the *Place* category. Below is the template code > with the manual edits in color. The first "_pageName" refers to data in > Cargo tables. The second "_pageName" is the current page being displayed, > which I don't know how to specify in this context. This code results in no > error and no text after the "ComposedOf" label. When viewing the place "Sol > System", the ComposedOf text should include links to Earth and Mars, since > they are both currently in the Place table as PartOf the Sol System. In > this context, the second _pageName should return "Sol System" (or > "Sol_System" ?). > > <noinclude> > {{#template_params:Type|PartOf (label=Part Of)|ComposedOf}} > {{#cargo_declare:_table=Place|Type=Page (allowed > values=SolarSystem,AsteroidBelt,Asteroid,Planet,WaterBody,Continent,GeographicEntity,Nation,SubNationalRegion,City,Neighborhood,Street,Building,Room)|PartOf=Page > |ComposedOf={{#cargo_query:table=Place|fields=Place._pageName|where = > PartOf HOLDS "_pageName"}}}} > </noinclude><includeonly>{{#cargo_store:_table=Place}} > {{#template_display:_format=standard}} > [[Category:Place]] > </includeonly> > > I pushed on "Recreate Data" in the Template menu, which may explain how > "ComposedOf" got added to the table. I did not add ComposedOf to the schema. > Here is the Place table: > > Page Type PartOf ComposedOf > Earth Planet Sol System > Mars Planet Sol System > Sol System SolarSystem > > > > -david > > > > On Mon, Aug 30, 2021 at 9:11 PM Sam Wilson <s...@samwilson.id.au> wrote: > >> I think the normal way to do this in Cargo would be not to have the >> inverse property stored in a page's data, but rather to query the inverse >> wherever required. So, for example, an Idaho page would define part_of >> as USA, and then on the USA page you could have a template that displays >> all the composed_of pages: {{#cargo query: tables = places | where = >> part_of HOLDS 'USA' }}. This way, there's no double-entry of values and >> so nothing to get out of sync. >> On 31/8/21 6:42 am, David Epstein wrote: >> >> If a class has a *composed_of *property and a *part_of* property, can I >> define these somewhere as inverse relationships? I'd like to set Idaho as >> *part_of* the USA and then (automatically) see that assignment in USA's >> *composed_of >> *list? >> >> Moreover, is it possible to specify that the properties have a more >> specific domain, not just any page but only pages from the category "Place"? >> >> >> >> >> >> >> _______________________________________________ >> MediaWiki-l mailing list -- mediawiki-l@lists.wikimedia.org >> List information: >> https://lists.wikimedia.org/postorius/lists/mediawiki-l.lists.wikimedia.org/ >> >> _______________________________________________ >> MediaWiki-l mailing list -- mediawiki-l@lists.wikimedia.org >> List information: >> https://lists.wikimedia.org/postorius/lists/mediawiki-l.lists.wikimedia.org/ >> > _______________________________________________ > MediaWiki-l mailing list -- mediawiki-l@lists.wikimedia.org > List information: > https://lists.wikimedia.org/postorius/lists/mediawiki-l.lists.wikimedia.org/ > -- WikiWorks · MediaWiki Consulting · http://wikiworks.com
_______________________________________________ MediaWiki-l mailing list -- mediawiki-l@lists.wikimedia.org List information: https://lists.wikimedia.org/postorius/lists/mediawiki-l.lists.wikimedia.org/