• Resolved sp4448

    (@sp4448)


    Is it possible to hide a blank field?

    I’m using a dynamic hyperlink like this:

    I tried using this and it didn’t work:
    <script>
    if (“”!=”$$FILENAME$$”) {
    document.write(““);
    }
    </script>

    How do I hide it if there’s no $$FILENAME$$?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @sp4448,

    You cannot use document.write in a dynamic hyperlink, but you can hide a blank field using an if-then-else macro. This feature is explained here:
    https://wpdataaccess.com/docs/data-explorer/dynamic-hyperlinks/

    Please scroll down to the if-then-else macro section. The nested macro examples shows how you can catch a blank field value.

    Let me know if you need further assistance.

    Good luck,
    Peter

    Thread Starter sp4448

    (@sp4448)

    I’m not familiar with macros and google isn’t being helpful.

    With the nested macro example, what does each line mean?

    This is what I’m guessing…

    If product image is ____ (blank? not blank?)
    and if product name equals sneakers
    show this image
    If product name does not equal sneakers
    show N.A.
    end macro
    If product image is ____ (blank?)
    show javascript link
    end macro

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @sp4448,

    You initial if statement:

    if (""!="$$FILENAME$$") {
    	...
    }

    Written as macro:

    #macro if "$$FILENAME$$" != ""
    	...   
    #macro end if

    Replace the … with your own HTML. It is simpler than javascript and above all much safer.

    Hope this helps,
    Peter

    Thread Starter sp4448

    (@sp4448)

    Thank you Peter! You’ve been incredibly helpful and patient.

    I was able to make it work with blank fields. It hid the field when blank, and didn’t hide it when not blank.

    On its own it works perfectly.

    However I was trying to include it as part of a paragraph and it won’t work then.

    This works:

    #macro if "$$FILENAME$$" != ""
    <img src=$$FILENAME$$> 
    #macro end if

    This doesn’t work:

    Other $$FIELD$$
    
    #macro if "$$FILENAME$$" != ""
    <img src=$$FILENAME$$> 
    #macro end if
    
    More $$FIELDS$$

    Is the latter possible?

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @sp4448,

    You can use other columns in a macro, but they have to be within the same table. You cannot access columns from another table.

    If you need to access a column from another table in a publication, you can write a view that contain the other column. The Data Publisher works with views just like tables. This is possible with projects as well, but eliminates the possibility to support transactions.

    Does this help?

    Thanks,
    Peter

    Thread Starter sp4448

    (@sp4448)

    They’re all in the same table

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi @sp4448,

    Please check your column name in the Data Explorer:
    – Open the Data Explorer
    – Find your table
    – Click Manage
    – Press tab Columns

    Make sure your write the column name exactly as shown on the Columns tab. Depending on your installation column names can be case sensitive.

    Hope this helps,
    Peter

    Thread Starter sp4448

    (@sp4448)

    All column names are uppercase and match exactly. They appear without a macro but won’t appear if using a macro.

    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Can you share your full dynamic hyperlink code? You can use the contact form on the plugin website if you prefer to share this information in private.

    Thanks,
    Peter

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Hide blank fields?’ is closed to new replies.