By: Anthony
Date: 2012-03-13
Time: 15:59
|
Still Merge Field When Empty
Is it possible to have TBS to not delete a section of html even if there is no data for that particular field? For example, if there is no data returned for the author field, I still want the table row to show.
<tr class="odd">
<th>Title ID</th>
<td>[titleblock.ID]</td>
</tr>
<tr class="even">
<th>Author</th>
<td>[titleblock.author]</td>
</tr>
<tr class="odd">
<th>Title Played</th>
<td>[titleblock.date_played]</td>
</tr>
|
|
By: Skrol29
Date: 2012-03-13
Time: 16:50
|
Re: Still Merge Field When Empty
Hi Anthony,
I guess when you say "no data returned for the author field" you mean "no item 'author' in the array".
If it's so, then you just have to add: [titleblock.author;noerr].
|
By: Anthony
Date: 2012-03-13
Time: 17:07
|
Re: Still Merge Field When Empty
I tried the following with noerr added, but the table row still does not display when there is no author data. Only for titles that already have an author field existing in the DB shows up. For those titles that do not have an author field in the DB, TBS removes the table row. I want the table row to still show with the "Author" header even though the field is blank.
<div>
<table>
<tr class="even">
<th>Title</th>
<td>[titleblock.title; block=div; p1=[songblock.ID]]</td>
</tr>
<tr class="odd">
<th>Title ID</th>
<td>[titleblock.ID]</td>
</tr>
<tr class="even">
<th>Author</th>
<td>[authorblock.name; block=tr; p1=[titleblock.ID]; noerr]</td>
</tr>
<tr class="odd">
<th>Title Played</th>
<td>[titleblock.date_played]</td>
</tr>
</table>
</div>
|
|
By: Skrol29
Date: 2012-03-14
Time: 11:42
|
Re: Still Merge Field When Empty
Hi Antony,
The problem is not the same. In this last snippet, you are using sub-blocks.
You can display the block even if there is no data using a "nodata" section.
Example:
<div>
<table>
<tr class="even">
<th>Title</th>
<td>[titleblock.title; block=div; p1=[songblock.ID]]</td>
</tr>
<tr class="odd">
<th>Title ID</th>
<td>[titleblock.ID]</td>
</tr>
<tr class="even">
<th>Author</th>
<td>[authorblock.name; block=tr; p1=[titleblock.ID]]</td>
</tr>
<tr class="even">
<th>Author</th>
<td>(none)[authorblock; block=tr; nodata]</td>
</tr>
<tr class="odd">
<th>Title Played</th>
<td>[titleblock.date_played]</td>
</tr>
</table>
</div>
|
|
By: Anthony
Date: 2012-03-14
Time: 21:17
|
Re: Still Merge Field When Empty
Do I just leave it as authorblock and not authorblock.name? Just putting authorblock, I get the output of "Array" in the web page.
|
By: Skrol29
Date: 2012-03-14
Time: 23:06
|
Re: Still Merge Field When Empty
> Do I just leave it as authorblock and not authorblock.name
The "nodata" section is supposed to be display when there is no data. I.e. you even don't have any "name" column.
The syntax without the column name is valid for TBS : it defines the block parameters without displaying data.
> Just putting authorblock, I get the output of "Array" in the web page.
It should not be.
|
By: Anthony
Date: 2012-03-15
Time: 16:32
|
Re: Still Merge Field When Empty
Ok, we had some changes to the database structure, and my latest attempt is shown at the end. When the html page is created, I get the titleblock to output just fine, but on cases where there is no tune, TBS removes that section altogether for any title records beyond the first title. However, in the first title record, I get the first tune record and then I get the "Tune" header text followed by "Array." For example here is what is seen on the html page output.
First table record shows:
1 Immortal, Invisible, God Only Wise
Title ID 351
Words Walter Chalmers Smith
Title Played 2012-03-15 06:41:08
Tune St. Denio (Joanna)
Tune Array
Music Welsh melody in John Robert’s Canaidau y Cyssegr, 1839
Tune Played 2012-03-15 06:41:08
Lyrics
|
Subsequent records that lack tunes in the database, show as:
2 Come, Thou Almighty King [ID: 132]
Title ID 132
Words
Title Played 2012-03-15 06:41:08
Lyrics
|
And now my template:
<div id="tabs-3">
<div class="titlesDetails">
<table>
<caption>
[titleblock.#] [titleblock.title; block=div; p1=[songblock.ID]]
</caption>
<tr>
<th>Title ID</th>
<td>[titleblock.ID]</td>
</tr>
<tr>
<th>Words</th>
<td>[titleblock.author; strconv=no]</td>
</tr>
<tr>
<th>Title Played</th>
<td>[titleblock.date_played]</td>
</tr>
<!-- <div> -->
<tr>
<th>Tune</th>
<td>[tuneblock.tune; block=div; p1=[songblock.ID]; p2=[titleblock.ID]]</td>
</tr>
<tr>
<th>Tune</th>
<td>[tuneblock; block=div; nodata]</td>
</tr>
<tr>
<th>Music</th>
<td>[tuneblock.composer; strconv=no]</td>
</tr>
<tr>
<th>Tune Played</th>
<td>[tuneblock.date_played]</td>
</tr>
<!-- </div> -->
<tr>
<th>Lyrics</th>
<td><pre>[titleblock.lyrics; strconv=no]</pre></td>
</tr>
</table>
</div>
</div>
|
|
By: Skrol29
Date: 2012-03-16
Time: 09:25
|
Re: Still Merge Field When Empty
Hi,
The TBS tag [tuneblock; block=div; nodata] is already embedded in the TBS block defined by [tuneblock.tune; block=div; p1=[songblock.ID]; p2=[titleblock.ID]].
Thus, its parameters block and nodata are simply ignored because it cannot be another block.
You should replace:
<!-- <div> -->
<tr>
<th>Tune</th>
<td>[tuneblock.tune; block=div; p1=[songblock.ID]; p2=[titleblock.ID]]</td>
</tr>
<tr>
<th>Tune</th>
<td>[tuneblock; block=div; nodata]</td>
</tr>
<tr>
<th>Music</th>
<td>[tuneblock.composer; strconv=no]</td>
</tr>
<tr>
<th>Tune Played</th>
<td>[tuneblock.date_played]</td>
</tr>
<!-- </div> -->
|
with:
<tr>
<th>Tune</th>
<td>[tuneblock.tune; block=tr+tr+tr; p1=[songblock.ID]; p2=[titleblock.ID]]</td>
</tr>
<th>Music</th>
<td>[tuneblock.composer; strconv=no]</td>
</tr>
<tr>
<th>Tune Played</th>
<td>[tuneblock.date_played]</td>
</tr>
<tr>
<th>Tune</th>
<td>[tuneblock; block=tr; nodata]</td>
</tr>
<tr>
|
In this snippet, the fist section is a normal section defined on three <tr> (block=tr+tr+tr), and the second section is a nodata section on one <tr> (block=tr).
No need to use extra HTML <div> tag.
|
|
Posting in progress.
Please wait...
|