• Hiding empty template variables in Ditto template#

  • worchyld Reply #1, 4 years, 3 months ago

    Reply
    I have a basic ditto template which has various template variables in the document and looks like this:

    <h2>[+tplvar_company_name+]</h2>
    <p>[+tplvar_description+]</p>
    <p>[+tplvar_address+]<br />
    [+tplvar_contact_name+]<br />
    <strong>[+tplvar_contact_position+]</strong>
    </p>
    <p>[+tplvar_telephone+]<br />
    [+tplvar_fax+]<br />
    [+tplvar_mobile+]<br />
    [+tplvar_skype+]<br />
    [+tplvar_email+]<br />
    [+tplvar_website+]
    </p>
    <p>
    <a href="#top">^ Top</a>
    </p>
    


    However sometimes there might not be any "skype", "email", or "telephone" data, so this means I get a lot of blank spaces because of the breaks (br).

    Q1. I would like to know how to tell Ditto to ignore any template variable (and the BR after it) if it is blank.

    Also, when I created template variables it asked me for a label (ie: "Website", "URL" or "company name").

    Q2. Is it possible for me to use these labels in my Ditto template without having me to re-typing them?

    ie:
    [+some_template_variable_label+] - [+some_template_variable_value+]<br />
    


    Many thanks.


  • heliotrope Reply #2, 4 years, 3 months ago

    Reply
    Hi,

    Q1. I would like to know how to tell Ditto to ignore any template variable (and the BR after it) if it is blank.

    [+tplvar_fax:isnot=``:then=`[+tplvar_fax+]<br />`+]
    


    for more information about PHx see the wiki

    :-)