Jump to content

Template:VerseRow: Difference between revisions

From Anandamakaranda
m 1 revision imported
No edit summary
Line 1: Line 1:
{{#cargo_store: _table=NakhaStotra
<!--
| document_id   = {{{document_id|}}}
  Template:VerseRow  (refactored — shared Verses table)
| chapter_id     = {{{chapter_id|}}}
  ══════════════════════════════════════════════════════
| verse_id       = {{{verse_id|}}}
  Stores verse data into a single shared `Verses` Cargo table
| verse_type     = {{{verse_type|}}}
  usable across ALL documents on grantha.io.
| verse_text     = {{{verse_text|}}}
 
| has_balabodhini  = {{{has_balabodhini|no}}}
  The `commentaries` field uses Cargo's  List (,) of String  type,
| has_mandabodhini = {{{has_mandabodhini|no}}}
  so you can query:
    WHERE commentaries HOLDS "balabodhini"
    WHERE commentaries HOLDS "shankarabhashya"
 
  Called automatically by Template:VerseBlock — do not call directly.
 
  Cargo table declaration (add inside <noinclude> on this template):
    {{#cargo_declare: _table=Verses
    | document_id  = String
    | chapter_id  = String
    | verse_id    = String
    | verse_type  = String
    | verse_text  = Text
    | commentaries = List (,) of String
    }}
-->
{{#cargo_store: _table=Verses
| document_id = {{{document_id|}}}
| chapter_id   = {{{chapter_id|}}}
| verse_id     = {{{verse_id|}}}
| verse_type   = {{{verse_type|}}}
| verse_text   = {{{verse_text|}}}
| commentaries = {{#if:{{{commentary1|}}}|{{{commentary1}}}}}{{#if:{{{commentary2|}}}|,{{{commentary2}}}}}{{#if:{{{commentary3|}}}|,{{{commentary3}}}}}{{#if:{{{commentary4|}}}|,{{{commentary4}}}}}{{#if:{{{commentary5|}}}|,{{{commentary5}}}}}
}}<!--store only-->
}}<!--store only-->
<noinclude>
{{#cargo_declare: _table=Verses
| document_id  = String
| chapter_id  = String
| verse_id    = String
| verse_type  = String
| verse_text  = Text
| commentaries = List (,) of String
}}
== Usage ==
Called by {{tl|VerseBlock}} automatically. Do not invoke directly.
=== Cargo table: Verses ===
One shared table for all documents. Query examples:
'''All verses in a chapter:'''
<pre>
{{#cargo_query:
  tables  = Verses
| fields  = verse_id, verse_type, verse_text
| where    = chapter_id = "NNS_C01"
| order by = verse_id ASC
| format  = table
}}
</pre>
'''All verses that have a specific commentary:'''
<pre>
{{#cargo_query:
  tables  = Verses
| fields  = verse_id, commentaries
| where    = document_id = "NNS"
  AND commentaries HOLDS "balabodhini"
| format  = table
}}
</pre>
'''Count commentaries per document:'''
<pre>
{{#cargo_query:
  tables  = Verses
| fields  = document_id, COUNT(*) = total_verses
| where    = commentaries HOLDS "shankarabhashya"
| group by = document_id
| format  = table
}}
</pre>
[[Category:Cargo store templates]]
</noinclude>

Revision as of 07:35, 10 March 2026


This template defines the table "Verses". View table. A replacement table has been generated for this table; View replacement table.

Usage

Called by Template:Tl automatically. Do not invoke directly.

Cargo table: Verses

One shared table for all documents. Query examples:

All verses in a chapter:

{{#cargo_query:
  tables   = Verses
| fields   = verse_id, verse_type, verse_text
| where    = chapter_id = "NNS_C01"
| order by = verse_id ASC
| format   = table
}}

All verses that have a specific commentary:

{{#cargo_query:
  tables   = Verses
| fields   = verse_id, commentaries
| where    = document_id = "NNS"
  AND commentaries HOLDS "balabodhini"
| format   = table
}}

Count commentaries per document:

{{#cargo_query:
  tables   = Verses
| fields   = document_id, COUNT(*) = total_verses
| where    = commentaries HOLDS "shankarabhashya"
| group by = document_id
| format   = table
}}