By: Anthony
Date: 2011-02-17
Time: 20:00
|
Conditional MergeBlock and Definition List
Looking for help on how to accomplish the following task. I want to display a block of html only if records have been found in the database. So, if no records are found, then do not display div "events"; otherwise if record found, show it. Also, how do I have the first record returned be placed in the first <dt> tag section, and then have the remaining records merged in the remaining <dt> section. I want to be able to apply a different css style to the first <dt>. Here's the template as it stands now, only half working. I put the <span> tag within the <dt> tag to get the mergeblock to work but it causes XHTML 1.1 Strict to fail because of the added <span>.
<div id="events">
<img src="[onshow.eventsimage; noerr]" width="200" height="51" alt="Events" />
<h3>Events</h3>
<dl class="list-widget">
<dt class="firstevent"><a href="#">[blk1.eventtitle]</a></dt>
<dd class="date firstevent"><span>[blk1.eventweekday]</span>
<br/>[blk1.eventdate]
</dd>
<dd class="time">[blk1.eventtime]</dd>
<span>
<dt><a href="">[blk1.eventtitle;block=span]</a></dt>
<dd class="date"><span>[blk1.eventweekday]</span>
<br/>[blk1.eventdate]
</dd>
<dd class="time">[blk1.eventtime]</dd>
</span>
</dl>
<ul>
<li><a href="#" title="View more events">View more events »</a></li>
</ul>
</div>
|
|
By: Skrol29
Date: 2011-02-17
Time: 22:14
|
Re: Conditional MergeBlock and Definition List
Hi Anthony,
>So, if no records are found, then do not display div "events"; otherwise if record found, show it.
Use "bmagnet=div",
see http://www.tinybutstrong.com/manual.php#html_block_prm_bmagnet
> Also, how do I have the first record returned be placed in the first <dt> tag section,
> and then have the remaining records merged in the remaining <dt>
Use conditional section, like this:
<span>
<dt>... (style 1) [blk1.eventtitle;block=span;when [blk1.#]=1] ...</dt>
<dd>...</dd>
<dd>...</dd>
</span>
<span>
<dt>... (style 2) [blk1.eventtitle;block=spandefault] </dt>
<dd>...</dd>
<dd>...</dd>
</span>
|
|
By: Anthony
Date: 2011-02-18
Time: 19:10
|
Re: Conditional MergeBlock and Definition List
Thanks for the reply. The bmagnet is just what I needed. I revised the code and it now works like I want. I ended up placing my span tags within comments tags so it will validate XHTML strict (span is not allowed in that location of a DL tag). TBS handles it by just repeating the span tag within the comment tag. I assume it is designed to work in this manner. Below is the template and then the output as view in the browser source.
<div id="events">
<img src="[onshow.eventsimage; noerr]" width="200" height="51" alt="Events" />
<h3>Events</h3>
<dl class="list-widget">
<!-- <span> -->
<dt class="firstevent"><a href="#">[eventsblock.eventtitle;block=span;when [eventsblock.#]=1]</a></dt>
<dd class="date firstevent"><span>[eventsblock.eventweekday]</span>
<br/>[eventsblock.eventdate]
</dd>
<!-- </span><span> -->
<dd class="time">[eventsblock.eventtime]</dd>
<dt><a href="">[eventsblock.eventtitle;block=span;when [eventsblock.#]+-1;bmagnet=div]</a></dt>
<dd class="date"><span>[eventsblock.eventweekday]</span>
<br/>[eventsblock.eventdate]
</dd>
<dd class="time">[eventsblock.eventtime]</dd>
<!-- </span> -->
</dl>
<ul>
<li><a href="#" title="View more events">View more events »</a></li>
</ul>
</div>
|
And now the source of the html after output to browser...
<div id="events">
<img src="assets/images/academic_side_menu.jpg" width="200" height="51" alt="Events" />
<h3>Events</h3>
<dl class="list-widget">
<!-- <span> -->
<dt class="firstevent"><a href="#">Day of Prayer</a></dt>
<dd class="date firstevent"><span>Fri.</span>
<br/>Feb. 18
</dd>
<!-- </span><span> -->
<dd class="time">8:00 AM - 12:00 PM</dd>
<dt><a href="">Student Preaching Day</a></dt>
<dd class="date"><span>Thu.</span>
<br/>Mar. 10
</dd>
<dd class="time">8:00 AM - 12:00 PM</dd>
<!-- </span><span> -->
<dd class="time">TBA</dd>
<dt><a href="">Annual Recitals</a></dt>
<dd class="date"><span>Fri.</span>
<br/>Apr. 15
</dd>
<dd class="time">TBA</dd>
<!-- </span><span> -->
<dd class="time">See schedule</dd>
<dt><a href="">Annual Bible Conference</a></dt>
<dd class="date"><span>Sun.</span>
<br/>Apr. 17
</dd>
<dd class="time">See schedule</dd>
<!-- </span> -->
</dl>
<ul>
<li><a href="#" title="View more events">View more events »</a></li>
</ul>
</div>
|
|
By: Anthony
Date: 2011-02-18
Time: 21:41
|
Re: Conditional MergeBlock and Definition List
Opps, I made one mistake in my template. Actually the <!-- </span><span> --> needed to go after the <dd class="time"> tag, else the data merge in does not match properly with the records. So, the corrected template is...
<div id="events">
<img src="[onshow.eventsimage; noerr]" width="200" height="51" alt="Events" />
<h3>Events</h3>
<dl class="list-widget">
<!-- <span> -->
<dt class="firstevent"><a href="#">[eventsblock.eventtitle;block=span;when [eventsblock.#]=1]</a></dt>
<dd class="date firstevent"><span>[eventsblock.eventweekday]</span>
<br/>[eventsblock.eventdate]
</dd>
<dd class="time">[eventsblock.eventtime]</dd>
<!-- </span><span> -->
<dt><a href="">[eventsblock.eventtitle;block=span;when [eventsblock.#]+-1;bmagnet=div]</a></dt>
<dd class="date"><span>[eventsblock.eventweekday]</span>
<br/>[eventsblock.eventdate]
</dd>
<dd class="time">[eventsblock.eventtime]</dd>
<!-- </span> -->
</dl>
<ul>
<li><a href="#" title="View more events">View more events »</a></li>
</ul>
</div>
|
|
|
Posting in progress.
Please wait...
|