Categories > TinyButStrong general >

Remove Previous Set of HTML Tags When Field Empty

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

Remove Previous Set of HTML Tags When Field Empty

Is it possible to use magnet to remove the previous set of HTML tags when a tbs field is empty? For example, in the template below, I want the span tags with the class "courseName" to be deleted when course_description field is empty. However, I still want the contents of that span to still display.

<div class="courseBlock">
    <ol>
        <li><span class="courseName">[degreeblock.course; block=li]</span>
        <span class="courseDescription">[degreeblock.course_description; magnet=span+(span); mtype=m+m]</span></li>
    </ol>
</div>
By: Skrol29
Date: 2012-04-26
Time: 00:15

Re: Remove Previous Set of HTML Tags When Field Empty

Hi Antony,

It is possible, but with the following way:
<div class="courseBlock">
<ol>
  <li>
    <span class="courseName">[degreeblock.course; block=li][degreeblock.course_description;magnet=span;ope=minv]</span>
    <span class="courseDescription">[degreeblock.course_description]</span>
  </li>
</ol>
</div>

Parameter "ope=minv" is described here:
http://www.tinybutstrong.com/manual.php#html_field_prm_ope
By: Anthony
Date: 2012-04-26
Time: 15:18

Re: Remove Previous Set of HTML Tags When Field Empty

Hello Skrol29,

Thanks for your reply. That works in removing the <span class="courseName">...</span> tag and everything in between. However, what I need to happen is for it to just remove the span tag and allow the course name field to display. So when course_description field is not empty, then we would have: <span class="courseName">Biology</span>. But when course_description field is empty, we would have just Biology to display.

I tried adding mtype=m+m to what you suggested:

[degreeblock.course_description;magnet=span;ope=minv;mtype=m+m]

However, that didn't work either. Any further suggestions?

Thanks.
By: Skrol29
Date: 2012-04-26
Time: 19:42

Re: Remove Previous Set of HTML Tags When Field Empty

Hi,

I'm surprised that the "m+m" doesn't work. It should.
Whatever, you can use parametter "att" instead, it should be nice too.
<div class="courseBlock">
<ol>
  <li>
    <span class="courseName">
      [degreeblock.course_description;att=span#class;if ''='[val]';then '';else 'courseName']
      [degreeblock.course; block=li]
    </span>
    <span class="courseDescription">[degreeblock.course_description]</span>
  </li>
</ol>
</div>