We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17665
    • 54 Posts
    I’m wondering about the best way to do the following...

    I have a template for a directory of churches. That template has a bunch of template variables like so:
    [*ChurchPastorFirstName*] [*ChurchPastorLastName*]<br>
    <br>
    Mailing Address:<br>
    [*MailingAddressStreet*]<br>
    [*MailingAddressStreet2*]<br>
    [*MailingAddressStreet3*]<br>
    [*MailingAddressCity*] [*MailingAddressState*] [*MailingAddressZip*]<br>
    [*MailingAddressCountry*]<br>
    <br>
    Shipping Address:<br>
    [*ShippingAddressStreet*]<br>
    [*ShippingAddressStreet2*]<br>
    [*ShippingAddressStreet3*]<br>
    [*ShippingAddressCity*] [*ShippingAddressState*] [*ShippingAddressZip*]<br>
    [*ShippingAddressCountry*]<br>
    <br>
    Phone: [*Phone*]<br>
    Fax: [*Fax*]<br>
    Email: [*Email*]<br>
    Website: [*Website*]<br>
    

    Now... my question is, what is the best way to hide or show data based on whether or not the TVs are empty? For example, I don’t want to show the Street2 or Street3 lines if the data is empty.

    Should I just do this in a snippet using php and the getTemplate functions?

    Thanks!
      • 1764
      • 680 Posts
      If you use <div> tags for each line instead of a
      then any empty divs should collapse and take up no space.

      One of these days I’ll probably work on a Regular expression widget with an "Only show if content exists" option. If the divs don’t work for you I might be able to work on it soon.
        • 32241
        • 1,495 Posts
        so for now we need to use snippet to do this, correct?
          Wendy Novianto
          [font=Verdana]PT DJAMOER Technology Media
          [font=Verdana]Xituz Media
          • 18397
          • 3,250 Posts
          Either div tags or a snippet, yes.
            • 6102
            • 17 Posts
            The Empty DIV TVs with css applied do not show in Firefox but they do in Internet Explorer.

            Does anyone know a solution for this?


            Example code:

            <table width="155" height="21"  border="0" cellpadding="0" cellspacing="0">
                 <tr>
                     <td width="151"><div class="NewsSideTitle">[*#LeftTitle1*]</div>
                                               <div class="BodyText">[*#LeftContent1*]</div></td>
                 </tr>
            </table>
            


            Thanks
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: ctusa at Feb 13, 2006, 01:14 PM

              The Empty DIV TVs with css applied do not show in Firefox but they do in Internet Explorer.

              Does anyone know a solution for this?

              This is an issue with FF and using DIVs inside tables for layout; it won’t work, at least not consistently or without some major CSS hacking. Your best bet is to lose the tables and use CSS positioning techniques instead, OR, if you don’t want to do that, try removing the DIVs so the content is output directly into the TD elements.
                • 6102
                • 17 Posts
                Actually, I like the way FF displays. IE is showing my empty [*#Title*]

                It is blank but the css background color is showing up with no text in it. I prefer how FF does not render it at all when empty.

                  • 10487 MODX Staff
                  • 1,535 Posts
                  Hi ctusa,

                  From what I can tell, the problem is to do with the ’.NewsSideTitle’ CSS style.

                  Try removing the ’width:100%’ from that style. I believe that is causing a problem with the div collapsing in IE.

                  Hope that helps, Garry
                    Garry Nutting
                    Senior Developer
                    MODX, LLC

                    Email: [email protected]
                    Twitter: @garryn
                    Web: modx.com
                    • 6726
                    • 7,075 Posts
                    This clearly highlight the need for conditionnal tags (which should at one point become available in MODx, as Raymond hinted).

                    Or could TV’s parsing be modified to output nothing if empty ? Could this be logged into FlySpray ?
                      .: COO - Commerce Guys - Community Driven Innovation :.


                      MODx est l&#39;outil id