DataSrc:DemoJan25/StrapiEvents: Difference between revisions

    From UNITApedia
    No edit summary
    No edit summary
    Line 1: Line 1:
    == Strapi Events with Subobjects ==
    <!-- 1) Fetch the data with #get_web_data -->
    {{#get_web_data:
    {{#get_web_data:
       |url    = https://unitapedia.univ-unita.eu/strapi/api/events
       |url    = https://unitapedia.univ-unita.eu/strapi/api/events
       |format  = JSON
       |format  = JSON
     
       |headers = Authorization: Bearer YOUR_TOKEN
      <!-- If "Public" role is enabled for events, you can remove this line -->
       |headers = Authorization: Bearer YOUR_TOKEN_HERE
     
      <!-- Pull fields from the JSON:
          - data.*.id
          - data.*.attributes.createdAt
          - data.*.attributes.updatedAt
          - data.*.attributes.publishedAt
      -->
       |data    = eventId        = data.*.id,
       |data    = eventId        = data.*.id,
                 eventCreated    = data.*.attributes.createdAt,
                 eventCreated    = data.*.attributes.createdAt,
                 eventUpdated    = data.*.attributes.updatedAt,
                 eventUpdated    = data.*.attributes.updatedAt,
                 eventPublished  = data.*.attributes.publishedAt
                 eventPublished  = data.*.attributes.publishedAt
       |debug  = 1
       |debug  = 1
    }}
    <!-- 2) Store each array element as a subobject via #store_external_table -->
    {{#store_external_table: StrapiEvents
      |event_id        = {{{eventId}}}
      |event_created    = {{{eventCreated}}}
      |event_updated    = {{{eventUpdated}}}
      |event_published  = {{{eventPublished}}}
    }}
    <!-- 3) Query the stored data using Semantic MediaWiki (#ask) -->
    {{#ask: [[-Has subobject::{{FULLPAGENAME}}]]
    |?event_id
    |?event_created
    |?event_updated
    |?event_published
    |format=table
    |headers=show
    |mainlabel=-
    }}
    }}

    Revision as of 16:44, 27 January 2025