Categories > TinyButStrong general >

Don't Repeat Some Fields When Displaying Block

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Anthony
Date: 2012-04-25
Time: 18:18

Don't Repeat Some Fields When Displaying Block

I have a block I need to display but some of the fields do not need to be repeated. I query my database with the following query:

SELECT d.name AS degree, d.description AS description, d.requirements AS requirements,
        c.name AS course, dd.yearofstudy AS yearofstudy, dd.semester AS semester
    FROM degrees d
    INNER JOIN degrees_details dd ON dd.degreeID = d.ID
    INNER JOIN courses c ON c.ID = dd.courseID
    WHERE d.ID = '" . $recordID . "' " .
    "ORDER BY dd.yearofstudy,dd.semester,dd.order

I need to have the block break when each yearofstudy and semester field is another year and semester. For example:

First Year (First Semester)
1. Course One
2. Course Two
3. Course Three

First Year (Second Semester)
1. Course One
2. Course Two
3. Course Three

Second Year (First Semester)
1. Course One
2. Course Two

Is there a way to have TBS do this without making multiple calls to the database? The sql query may return a different number of years depending on the degree. I have a template like so, but I don't know how I am going to construct the block to output. Any suggestions?

<div id='right_col'>
   <h2>[degreeblock.degree]</h2>
      <h3>Description</h3>
         <p>[degreeblock.description]</p>
      <h3>[degreeblock.yearofstudy]<span>([degreeblock.semester; magnet=span])</span></h3>
         <ol>
            <li>[degreeblock.course]</li>
         </ol>
</div>
By: Anthony
Date: 2012-04-25
Time: 19:21

Re: Don't Repeat Some Fields When Displaying Block

Ok, I think I have found the answer. This template appears to work for what I am wanting:

<div id='right_col'>
           <h2>[degreeblock.degree;block=h2+h3+p;headergrp=degree]</h2>
        <h3>Description</h3>
            <p>[degreeblock.description]</p>
        <h3>[degreeblock.yearofstudy]<span>([degreeblock.semester;block=h3;parentgrp=semester])</span></h3>
            <ol>[degreeblock;block=ol;parentgrp=semester]
                <li>[degreeblock.course;block=li]</li>
                    </ol>
</div>
By: Skrol29
Date: 2012-04-25
Time: 22:59

Re: Don't Repeat Some Fields When Displaying Block

Yep, "headergrp" is the solution.